Layout

Mechanisms of creating layouts.

Contents:

§ Centering

.text-align:center center-aligns text.

An element with class .center centers a single child element using display: grid; place-items: center.

.align-content:center vertically aligns content in the center of the alignment container. Flexbox no longer required! We also provide .align-content:end.

§ Text columns

The .textcolumns class creates multi-column text using the CSS column-width property. The column width can be set with the --col-width variable. Protip: consider using the ch unit to set column widths.

When combined with the <dl> element, missing.css will prevent orphans and widows in supported browsers. For full support, wrap pairs of <dt> and <dd> elements in a <div>.

Example: Columned details list markup (partial support)
<dl class="textcolumns">
  <dt>Term 1
  <dd>This is an explaination of the first term.
  <!-- ... -->
</dl>

Term 1
This is an explaination of the first term.
Term 2
This is an explaination of the second term.
Term 3
This is an explaination of the third term, and missing.css will prevent it from being split if the browser supports it.
Term 4
This is an explaination of the fourth term.
Example: Columned details list markup (full support)
<dl class="textcolumns">
  <div>
  <dt>Term 1
  <dd>This is an explaination of the first term, and missing.css will make sure it doesn't get split from its sibling `<dt>` tag.
  </div>
  <!-- ... -->
</dl>

Term 1
This is an explaination of the first term.
Term 2
This is an explaination of the second term.
Term 3
This is an explaination of the third term, and missing.css will prevent it from being split in all supported browsers.
Term 4
This is an explaination of the fourth term.

§ Flow gap

The .flow-gap class adds vertical margins between its children.

§ Full-size

Add the .fullbleed class to make an element go outside its container and span the whole width of the viewport.

The .fullscreen class will size an element to fill the screen.

§ Layout utilities

Add some padding with .padding, or a margin with .margin. The amount of margin or padding is determined by the density utilities.

Add padding or margin in specific axes with the following classes.

Automatic margin is provided with the following:

To remove padding or margin, use one of the following classes:

Make an element full-width with the .width:100% class. Similarly with .height:100%.

§ Border utilities

Add a border with .border; you can target specific axes with these classes:

Borders can be removed by using .border:none or one of the following classes:


The .nested-list class removes extraneous margins in nested lists. Deprecated: Will be removed in version 2.0. In the future, nested lists will not have margins by default. You can add them back in using <li><p> as needed.

Example: Nested list markup
<div class="flex-switch">
  <div>
    <strong>Regular list</strong>
    <ul><li>Items
        <ul><li>Item 1
            <li>Item 2</ul>
        <li>Widgets
        <ul><li>Widget 1
            <li>Widget 2</ul>
    </ul>
  </div>
  <div>
    <strong>Nested list</strong>
    <ul class="nested-list">
      <li>Items
        <ul><li>Item 1
            <li>Item 2</ul>
      <li>Widgets
        <ul><li>Widget 1
            <li>Widget 2</ul>
    </ul>
  </div>
</div>
Regular list
  • Items
    • Item 1
    • Item 2
  • Widgets
    • Widget 1
    • Widget 2
Nested list
  • Items
    • Item 1
    • Item 2
  • Widgets
    • Widget 1
    • Widget 2

§ Aspect Ratio

To set the aspect ratio of an element, use the aspect-ratio CSS property:

<style>#aspect-ratio-example > .box { height: 10vh }</style>
<div id="aspect-ratio-example" class="flex-row flex-wrap:wrap">
  <div class="box" style="aspect-ratio: 1/1">1:1</div>
  <div class="box" style="aspect-ratio: 4/3">4:3</div>
  <div class="box" style="aspect-ratio: 16/9">16:9</div>
  <div class="box" style="aspect-ratio: 2/1">2:1</div>
  <div class="box" style="aspect-ratio: 2/3">2:3</div>
  <div class="box" style="aspect-ratio: 16/10">16:10</div>
  <div class="box" style="aspect-ratio: 21/9">21:9</div>
  <div class="box" style="aspect-ratio: 4/1">4:1</div>
</div>
1:1
4:3
16:9
2:1
2:3
16:10
21:9

§ Scrolling

Set the overflow property with these utility classes.

.overflow:auto
Show scrollbars if needed.
.overflow:scroll
Always show scrollbars (use .overflow-x:scroll or .overflow-y:scroll to set on a specific axis).
.overflow:clip
Overflow content is clipped at the element's padding box. Can be set per axis using .overflow-x:clip or .overflow-y:clip, and the clip margin can be extended using the overflow-clip-margin CSS property.

Info: When using the .overflow:scroll utilities, it is recommended to add the element to the tabbing order (tabindex=0) so that the container can be scrolled using the keyboard.

§ Pseudo-tables

The .table class makes an element act like a table for the purposes of layout. The .row class can be used to create a table row, or you can make all descendants of an element into rows with .rows.

Example: Pseudo-table markup for aligning forms
<form class="table rows">
  <p>
      <label for=name>Name</label>
      <input type=text id=name name=name>
  </p>
  <p>
      <label for=adr>Address</label>
      <input type=text id=adr name=adr>
  </p>
</form>

Pseudo-tables work nicely with description lists:

Example: Pseudo-table markup for description lists
<dl class="table rows" style="width: auto;">
  <div><dt>Name:     <dd>Anakin Skywalker</div>
  <div><dt>Alias:    <dd>Darth Vader     </div>
  <div><dt>Species:  <dd>Human           </div>
  <div><dt>Gender:   <dd>Male            </div>
  <div><dt>Spouse:   <dd>Padmé Amadala   </div>
  <div><dt>Homeworld:<dd>Tatooine        </div>
</dl>

Name:
Anakin Skywalker
Alias:
Darth Vader
Species:
Human
Gender:
Male
Spouse:
Padmé Amadala
Homeworld:
Tatooine

§ Positioning

.block
Set display: block.
.inline
Set display: inline.
.contents
Set display: contents.
.fixed
Set position: fixed.
.sticky
Set position: sticky.
.top
Set top: 0. Use together with .fixed or .sticky.
.right
Set right: 0. See .top.
.bottom
Set bottom: 0. See .top.
.left
Set left: 0. See .top.
.float:left
Set float: left.
.float:right
Set float: right.

§ Printing

Missing.css attempts to prevent page breaks inside of grouped content and after headings when printed. Additionally, collapsed <details> elements will be revealed during printing in supported browsers.

During printing, missing.css will also annotate <a> and <abbr> tags by displaying an ::after pseudo-element that contains the href or title attribute value in parenthesis. You can disable these annotations by placing the following class on a parent element:

.annotations@print:disabled
Disable print annotations on child elements.
Example: Print annotations

This is a representation of what print annotations will look like when a webpage is being printed.

Print annotations utilize CSS rules in conjunction with semantic HTML tags to display extra information that is typically communicated via hypertext.