And that’s okay

21.01.23

In this – our first genuine post – I will describe these three elements and how they interact with the content of our pages. Understanding the box model and positioning is key to create aesthetically salient and visually pleasing websites.

Exciting stuff.

So, what’s inside the BOX MODEL?

“The CSS box model is essentially a box that wraps around every HTML element. It consists of: Margins, border, padding, and the actual content."

Although w3schools is clinically accurate, I prefer to imagine each element as a picture frame on a wall.

pictures hanging on a wall

If we focus on one of the frames, we can see that it is different from the rest but it also shares some similarities with the group.

pictures hanging on a wall, one is highlighted

Look at these photographs. Each frame is full of content and these images have both a height and a width.

pictures hanging on a wall, their contents are highlighted

External to the content we find the padding. Visualised here as completely enveloping the content, however the top, bottom, left & right properties can be edited individually or removed all together.

pictures hanging on wall, the passe-partout is highlighted

The third element of the box model is our border. Below you’ll see this makes up the frame of the image and much like a picture frame can be entirely customed with properties such as thickness, style, color, etc.

a framed picture. the frame is highlighted

Lastly, we find the space beyond the frame, the wall if you will. Much like padding, this can be visualised as a box.

pictures hanging on a wall. one has the area of wall surrounding it highlighted

Or edited individually, creating the borders between objects.

pictures hanging on a wall. the distance between them is highlighted

Or the entire wall, moving everything away from the edges of the page. My photoshop license expired halfway through editing these pictures so you might have to use your imagination.

Or consult the markup below:

pictures hanging on wall. the wall is highlighted

Margin & padding are to be taken most seriously. One small edit and you’ll break your entire heckin' page.