If you’re seeing this, the site behind it is likely broken!

Hi, there. I use these course sites as little sandboxes to experiment with and learn various “brand new” CSS properties—and your browser does not support (at least) one of them. Apologies. It “should” always work in current/updating Safari and Chrome!

  • Typography & Interaction

    ’25–26

  • The Syllabus

  • Our Class

  • Unit Nº 1: “Type and the Web”

    Wks. 1–6

    • Week Nº 1

      Aug. 29

    • Everything Is a “Web Page”

    • Week Nº 2

      Sep. 5

    • It’s All About Type

    • Week Nº 3

      Sep. 12

    • An Intro to HTML

    • Week Nº 4

      Sep. 19

    • An Intro to CSS

    • Week Nº 5

      Sep. 26

    • The Box Model

    • Boxes Within Boxes Within Boxes Within Boxes

      For real layout, the we first need to understand how CSS sizes elements⁠—and how we can add space between them. This is called the the box model, as everything on the web begins as a rectangle.

      • Introduction to CSS Layout – MDN
        As usual.

      • Layout – web.dev
        This gets into grid and flex; we’ll talk about those next unit.

      • Learn CSS Layout
        An old-but-still-good run-through.

      …Use the effectiveness of the former “background” quite deliberately, and consider the blank white spaces on the paper as formal elements just as much as the areas of black type.

      Jan Tschichold, 1928

      With box-sizing: content-box; per the spec.
      With box-sizing: border-box; the defacto standard. Most CSS resets will do this for you! Like we said, very common.

      By default, all browsers’ user-agent styles have an unfortunate default⁠—box-sizing: content-box;⁠—which means that the padding (and border) exists outside the content inline-size/​width or block-size/​height⁠—so padding (and border) is then an outset.

      But this is often unintuitive for designers and doesn’t fit with most web design patterns⁠—so it is very, very common (nearly universal) to instead override this to box-sizing: border-box;⁠—which makes padding and border exist inside the content dimensions. Then padding (and border) is easier to think of as an inset. W3C might have got this default wrong. Good ol’ CSS!

      Let’s take a look at this box, going inside-to-outside.

      Content

      The content area is the guts of the element, usually text or an image. Its dimensions are defined by that content, but also can be specified directly via width or height⁠—or inline-size and block-size. (More on those soon.)

      Be sure to look at the HTML here! It’s a similar structure throughout.

      Note: all styles shown are explicit

      We’ve pulled our standard CSS reset into the <head> for all of these examples, so we are only seeing the styles that are expressly written out here⁠—no defaults!

      Padding

      Next comes padding, which extends the element’s area around the content. It’s easiest to think of this as an inset (if we’ve made our box-sizing the more-intuitive border-box, above):

      Padding – MDN
      There will be many of these.

      A Sidebar About Shorthand

      Know that padding⁠—and many other properties, including border and margin⁠—can be specified with a shorthand property to make it easier to use the same spacing all around, or shared top/​bottom and left/​right.

      Shorthand Properties – MDN
      Be wary of the siren call of shorthand properties!

      1 value:

      All Directions/​Sides
      2 values:

      top/bottom left/right
      3 values:

      top left/right bottom
      4 values:

      top right bottom left
      						section { padding: 1rem; }
      section { padding: 1rem 2rem; }
      section { padding: 1rem 2rem 4rem; }
      section { padding: 1rem 2rem 4rem 2rem; }
      
      			
      	

      These three- and four-value rules are often harder to read and quickly understand though, so we tend to avoid them. You can always write the individual directions out, for clarity! (And cleaner diffs, with whole-line changes.)

      						section {
      	padding-top: 1rem;
      	padding-bottom: 4rem;
      	padding-right: 2rem;
      	padding-left: 2rem;
      }
      
      			
      	

      …and Logical Properties

      You can also now define all your box model properties using logical directions⁠—meaning instead of physical (top/​bottom, left/​right) orientations, you can map your rules to the flow of the text (block-start/​block-end, inline-start/​inline-end).

      CSS Logical Properties
      Adrian Roselli has a very thorough explanation.

      In horizontal, left-to-right writing modes (as in English):

      						/* These horizontal physical directions: */
      padding-left: 1rem;
      padding-right: 1rem;
      
      /* Map to these logical directions: */
      padding-inline-start: 1rem;
      padding-inline-end: 1rem;
      
      /* And this combined property: */
      padding-inline: 1rem;
      
      /* Also this physical dimension: */
      width: 20rem;
      
      /* Becomes this logical one: */
      inline-size: 20rem;
      
      			
      	
      						/* Same for the vertical directions: */
      padding-top: 1rem;
      padding-bottom: 1rem;
      
      /* Mapping to these: */
      padding-block-start: 1rem;
      padding-block-end: 1rem;
      
      /* And this shorthand for both: */
      padding-block: 1rem;
      
      /* This physical size: */
      height: 20rem;
      
      /* Becomes this logical one: */
      block-size: 20rem;
      
      			
      	

      This start /​ end terminology will come up later with flexbox and grid, so it is a good habit/​mindset to get into!

      This allows your design/​styles to behave in a logically (if not physically) consistent way across languages with varied writing modes and different text directions. You can write styles that work even when your site is translated! (And the two-direction shorthand is nice, here.)

      Logical properties make sense

      This is a real mental model shift⁠—for your instructors, too! We’re going to try using/​referencing logical properties exclusively this year. It is the correct and modern way!

      Border

      Back to our box model, moving outwards, with border. Border is… the border around an element. It has its own border-width, border-color, and also border-style:

      Border – MDN
      Our first non-text design element! You are allowed.

      The shorthand border-block-start property value order here doesn’t matter! Isn’t CSS …logical.

      The various border-style options:

      Look at all those borders.

      And fun with border-radius:

      Margin

      The last part of our box is margin⁠—the space around an element, empty/​white-space area that is used to separate an element from its siblings. Like padding and border, you can specify it all around or on individual sides:

      Margin – MDN
      The space between things.

      This is away to suggest a multi-column feeling while keeping your reading flow clear.

      Margin has a couple tricks up its sleeve. First, it can have negative values⁠—which will eat up/​remove space between elements. (padding and border only take up space.) Just add a minus before the value and watch it bring things closer together:

      The first element pulls the second element closer with a negative margin.

      Also margins collapse, meaning that they are sometimes combined into a single value (whichever is largest) between two elements. This happens most often on adjacent siblings, and is both useful and an absolute pain:

      You might expect the margin between the first two section to be 10rem, but it is only 6rem! They have collapsed to the larger value.

      And Their Units

      Okay, so now we have all these box properties⁠—but how do we specify the dimensions? CSS has many length units, used for inline-size, block-size, and also padding, border, margin, and even font-size. (Picas, anyone?) We’ll look at some common ones.

      <length> – MDN
      Length is used by many properties!

      Absolute Units

      Maybe the easiest ones to understand, these are fixed to physical (well, sort of) sizes. In general, we try and avoid these as they are necessarily brittle. Remember: the web is not a “physical” medium!

      With the many vagaries of screen size and density, the physical/​ruler lengths will only be correct when you print. And maybe not even then!

      						.pixels {
      	block-size: 360px;
      	inline-size: 720px;
      }
      
      .inches {
      	block-size: 5in;
      	inline-size: 10in;
      }
      
      .mm {
      	block-size: 84mm;
      	inline-size: 400mm;
      }
      
      .pt {
      	block-size: 12pt;
      	inline-size: 72pt;
      }
      
      			
      	

      Relative Units

      Most of the time we want to use relative units, which depend on and respond to their context⁠—particularly as we think ahead to responsive design.

      These are distinctly and intrinsically web measurements.

      						/* Relative to nearest “sized” ancestor. */
      .percentage {
      	block-size: 90%;
      	inline-size: 75%;
      }
      
      /* Relative to viewport height/width. */
      .viewport {
      	block-size: 75vh;
      	inline-size: 80vw;
      }
      
      /* Relative to `:root`/`html` font-size. */
      /* These define our typographic systems! */
      .rem {
      	block-size: 12rem;
      	inline-size: 2.4rem;
      }
      
      /* These are relative to an element’s font-size. */
      /* `1em` is “one line.” */
      .em { block-size: 14em; }
      
      /* The cap height. */
      .cap { block-size: 1cap; }
      
      /* Roughly one letter width. */
      .ch { inline-size: 1ch; }
      
      /* The x-height. */
      .ex { block-size: 1ex; }
      
      /* A line-height (baseline to baseline). */
      .lh { block-size: 1lh; }
      
      /* These all have `:root`-relative versions too: */
      /* `rch` `rcap` `rex` `rlh` */
      
      			
      	

      Combine Them With a calc()

      Often you will want to use different units together! Mixing types or otherwise doing some maths. For this we have the calc() function.

      						.flexible-and-fixed {
      	inline-size: calc(50% - 2rem);
      }
      
      .computer-do-the-math {
      	inline-size: calc(100% / 12);
      }
      
      			
      	

      Limit/​Constrain Them

      You’ll often want to set limits/​constraints on values⁠—particularly with flexible, relative units (and responsive design, which we’ll talk about soon.)

      You can usually set minimums and maximums by using the prefixes min- and max-.

      						.constrained-width {
      	min-inline-size: 12rem;
      	inline-size: 50%;
      	max-inline-size: 24rem;
      }
      
      .constrained-height {
      	min-block-size: 6rem;
      	block-size: 100%;
      	max-block-size: 12rem;
      }
      
      /* Handy to watch your line lengths! */
      p {
      	max-inline-size: 65ch; /* 65ish letters. */
      }
      
      			
      	

      CSS is big and massive and overwhelming and sometimes indefensibly nonsensical⁠—but remember that you can do a surprising amount with just these basic properties!

      No matter how complex it gets, it really always comes back to these basics.

      Position

      With an idea of how elements take up space, now we’ll look at how they exist and move together in the document flow. The CSS property position sets this relationship.

      Position – MDN
      Interesting web work often uses position.

      Static

      By default, every element is static⁠—just meaning its normal, stacked position in the document.

      You’ll rarely, if ever, actually set this yourself⁠—it’s the default!

      Nothing changes here⁠—static is the default. Be sure to scroll these examples!

      Relative

      The first thing we might want to do is adjust an element from that normal static position, which we can do with relative positioning.

      Once you have set position: relative; you can use the logical inset-block-start, inset-inline-end, inset-block-end, and inset-inline-start values (with any of the units, above) to move the element away from its default, normal position in the flow:

      Note the space⁠—the element still exists/​takes up space in the flow.

      Absolute

      absolute positioning is somewhat similar to relative⁠—but instead of placing an element in relation to its own default position, it uses the position of its nearest positioned ancestor as the origin.

      So absolute elements will go “up the tree” of parents and wrapper elements until they find one set to anything other than default/​static⁠—then the same offset properties the element around from there.

      Importantly, position: absolute; also removes the element from the normal document flow⁠—meaning it takes up no space in the page layout.

      This is often used for exacting, specific design element placement. But it is inherently brittle⁠!

      The element is out of the flow, and placed according to the relative parent.

      Fixed

      fixed positioning also removes the element from the document flow, but it places elements with relation to the browser viewport⁠—the boundaries of the window or device.

      So position: fixed; brings the element completely out of the page’s normal flow, like it is sitting on its own separate layer.

      This is often used for things like navigation elements.

      Try doing this in print.

      Sticky

      The most recent addition to the position party, position: sticky; elements are placed according to the normal flow of the document, like static, until their nearest scrolling ancestor (usually the viewport) moves past them. The element is then stuck in relation to this element.

      This is often used for headers on tables and lists.

      You’ll hear Michael say this a lot: this always feels very web-y.

      “Depth”

      Okay, z-index is not strictly positioning⁠—it is a separate property. You can see that all these position properties have given us ways to make things overlap, and z-index is how we can decide the front-to-back ordering (think z-axis).

      Z-Index – MDN
      This can be tricky to work with!

      By default, items that are lower in the HTML (coming after each other) are in front of higher, earlier elements:

      The two position properties both create new stacking contexts, z-index: 1; moves even elements in front.

      A whole lot of things make a new stacking context (including most position changes) which is kind of like a group (or a Figma frame) that has its own internal depth/​overlap order.

      No amount of internal z-index adjustments can “break” something out of that group⁠—which is one of the reasons why z can be really difficult to understand and tricky to use. But you can always adjust the z-index of the group, as we do here!

      Display

      In our HTML introduction we briefly talked about block and inline elements⁠—as set by the user-agent styles. These are the first two examples of the display property.

      Display – MDN
      Our block and inline elements (and later, grid and flex).

      Block

      As we discussed, most HTML elements are block-level by default. But you can also set display: block; manually on an inline element, too. This would mean that it starts on a new line, takes up the full width available, and you can specify a block-size, inline-size, and use margin above and below:

      Whenever you are linking a whole area (like an image and text together), safe bet that you want block.

      Inline

      And then going the other way, you can make block elements switch to inline with display: inline;. They will no longer start on their own lines, will only take up as much space as their content/​children, and don’t accept block-size or inline-size (or any -block-start/​-block-end) properties:

      The white-space property pre-vents the spaces in the paragraphs from collapsing!

      But Also inline-block

      You can also combine the qualities of block and inline with display: inline-block;. These elements take block-size and inline-size (and vertical margin) like block-level elements, but do not start on their own line:

      And Sometimes none

      Setting display: none; hides an element visually (and from screen readers) in the document⁠—as well as taking it out of the flow. (Keep in mind the HTML is still there, if someone opens up the source code.)

      This is a common way to hide/​show (by setting another display property) elements on the page, but it will reflow the document when applied⁠—as if the element is actually added/​removed from the HTML:

      Poof. Like it wasn’t even there.

      …vs. Visibility?

      You can also hide something visually without taking it out of the document flow, which is useful when you don’t want the page to jump/​reflow when something appears/​disappears.

      Visibility – MDN
      This also hides elements from assistive technologies (screen readers).

      Setting visibility: hidden; keeps the space an element had before, but makes it invisible and unable to be interacted with. The value visible is the default:

      …vs. Opacity?

      Another way to hide an element visually is to adjust opacity, which uses values on a scale from 0⁠–⁠1 or 0%⁠–⁠100%. This differs from visibility because elements with no (or partial) opacity can still be interacted with:

      Opacity – MDN
      The entire element and its descendents are adjusted, as one.

      You can still select the text (or click links) of not-fully-opaque elements.

      Keep in mind that display: none;, visibility: hidden;, and opacity: 0; only hide things in the rendered browser view. The HTML is always still visible in the source code!

      What About Floats?

      Oh right, floats. Sometimes you’ll want to have an image or block flow within a block of text. There are a lot of ways to do this now, but the oldest (and sometimes still the trickiest) is a float.

      Floats – MDN
      You don’t see these used as much, anymore!

      Left and Right

      The declarations float: inline-start; and float: inline-end; take an element out of the normal flow and place it on the left or right side of its parent container.

      Any text siblings will then flow around the element⁠—like a text wrap⁠—filling up any available space to its side. They will go as far up as the top of the floated element:

      Don’t Forget to clear

      Since this takes the floated element out of the flow, if we want the following element (often another text block, like a <p>) to not move up it needs to be cleared with clear: inline-start; , clear: inline-end;, or clear: both;.

      Applied on the following element, it will make it stay entirely below (clear of) the floated element:

      Uh oh, classic float problem on the second one.

      If you have a parent wrapper and no following element, there won’t be anything there to clear the float⁠—meaning the parent will collapse down to the size of the text content. Almost never what you want.

      You can solve this broken look with a clearfix hack, which uses a pseudo-element as an ersatz last-child to clear the container.

      Much better. :after is a pseudo-element⁠—which acts here as a last child that clears the div.

      Generally, folks try and avoid floats⁠—they aren’t common in modern design patterns and have been giving people headaches for… decades now.

      They require you to know how long your content is and also how big your viewport/​page will be⁠—both things that you don’t always have control over in responsive/​mobile 2025. But sometimes they are still the only thing that can do what you need!

      What about flex and grid?

      We’ll cover these next unit! They’ll make your (layout) life easier.

      E.g.: ____________   H1 has a 1 character margin   So does H2   P starts here and could go on forever. Wow, a 5 character left margin sure looks great! _____ | + + | Wow, you can do | @ | images as well? | --- | Then you'll |_____| want a 1 character margin on the left side. Until, you're below the image that is.   This is where we [find] the simple stacked box model is a bit too simple.

      Håkon Wium Lie, 1995

    • Project Nº 1: “Manuscript”

      Oct. 3

    • Week Nº 6

      Oct. 3

  • Unit Nº 2: “There Is No Perfect Layout”

    Wks. 7–10

    • Week Nº 7

      Oct. 10

    • Responsive Design

    • DevTools (Web Inspector)

    • Week Nº 8

      Oct. 17

    • Finally, Flexbox

    • And (CSS) Grid

    • Week Nº 9

      Oct. 24

    • Some Additional, Advanced CSS

    • Project Nº 2: “Spread”

      Oct. 31

    • Week Nº 10

      Oct. 31

  • Unit Nº 3: “Typography as Interface”

    Wks. 11–15

    • Week Nº 11

      Nov. 7

    • Working with Images

    • Week Nº 12

      Nov. 14

    • Week Nº 13

      Nov. 21

    • Thanksgiving Week

    • Project Nº 3: “Binding”

      Dec. 5

    • Week Nº 14

      Dec. 5

    • Week Nº 15

      Dec. 12

  • Winter Break

  • Unit Nº 4: “Interface as Interface”

    Wks. 16–21

    • Week Nº 16

      Jan. 21

    • Week Nº 17

      Jan. 28

    • An Intro to JavaScript

    • Week Nº 18

      Feb. 4

    • Some More JavaScript

    • Week Nº 19

      Feb. 11

    • Week Nº 20

      Feb. 18

    • Project Nº 4: “Links”

      Feb. 25

    • Week Nº 21

      Feb. 25

  • Unit Nº 5: “If All You Have Is a Hammer, Everything Looks like a Nail”

    Wks. 22–30

    • Week Nº 22

      Mar. 4

    • Putting a (Link/​Meta) Bow on It

    • Week Nº 23

      Mar. 11

    • Spring Break

    • Week Nº 24

      Mar. 25

    • Week Nº 25

      Apr. 1

    • Week Nº 26

      Apr. 8

    • Week Nº 27

      Apr. 15

    • Project Nº 5: “Functions”

      Apr. 22

    • Week Nº 28

      Apr. 22

    • Week Nº 29

      Apr. 29

    • Week Nº 30

      May 6

    • “Everything Else”

    • The end