liveBook · Manning

Content property

As explained in Tiny CSS Projects

The CSS content property specifies generated content for an element or pseudo-element.

The CSS content property inserts generated content, most often through the ::before and ::after pseudo-elements. It can add quotation marks, punctuation, or an empty box used to build a visual control. section 4.1.6 section 10.3.5

Common uses include:

  • Add opening and closing quotation marks with content: open-quote and content: close-quote; these use symbols defined by the quotes property or the document language. section 4.1.6
  • Insert punctuation after description terms with a declaration such as dt::after { content: ": "; }. section 8.2.5
  • Create an empty, display:block pseudo-element that can become the inner disk or check mark of a custom radio button or checkbox. section 10.3.5

Add quotation marks to a blockquote

blockquote::before { content: open-quote; } blockquote::after { content: close-quote; } These declarations add language-appropriate opening and closing marks without placing the symbols manually in the HTML. section 4.1.6

Listing 8.13 Styling the description list
th, dt {             #1
  color: #3a3a3a;
  font-weight: normal;
  font-size: .875em;
}
 
dt::after {          #2
  content: ": ";     #2
}                    #2

Inspect the description-list example to see content used with ::after to insert a colon and space after every term. section 8.2.5

How Tiny CSS Projects covers it

How deep it goes
Explains literal, keyword, and empty values through three interface examples, but does not develop a complete value reference.
Examples
Uses blockquote quotation marks, description-list colons, and invisible inner boxes for radio buttons and checkboxes.
What it assumes
Assumes basic CSS selectors and declarations while demonstrating pseudo-elements through blockquotes, description lists, and inputs.
What you can do after
Apply it via CSS pseudo-elements to add quotation marks, separators, or structural shapes to styled interface elements.
How it connects
Connects generated content with pseudo-elements, the quotes property, the attr() function, and form-control styling.

Also explained in

Compare how 2 books explain content property →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.