Skip to main content

CSS Default Values and Entities

1. CSS Default Property Values

Every CSS property has an initial value defined by the specification. Understanding defaults helps you know when a rule is actually needed versus when you're just confirming the default.

Most Important Defaults

PropertyDefault ValueNotes
displayinlineMost elements; block for divs, headings, sections
positionstatictop/left have no effect on static
visibilityvisibleElement and children show
opacity1Fully opaque
overflowvisibleContent flows outside the box
z-indexautoNo stacking context created
floatnoneNo floating
box-sizingcontent-boxWidth doesn't include padding/border
colorBrowser-definedUsually black or system UI color
background-colortransparentNo background fill
background-imagenone
border0 none currentColorInvisible by default
margin0(Some elements like <p>, <h1> have browser-defined margin)
padding0
widthautoFills block-level container
heightautoShrinks to content
max-widthnoneNo limit
min-widthautoContent-dependent
font-sizemedium (16px in most browsers)
font-weightnormal (400)
line-heightnormal (~1.2)Browser-dependent
text-decorationnone(Links default to underline)
cursorautoBrowser-chosen cursor
transitionnoneNo animation on property change
animationnone
transformnoneNo transformation
flex-directionrowLeft-to-right
flex-wrapnowrapSingle line
justify-contentflex-start
align-itemsstretch
grid-auto-flowrowFills row by row
object-fitfillImage stretches to fill (distorts!)

Inherited vs Non-Inherited Properties

Inherited (children get parent's value by default):

  • color, font-*, line-height, letter-spacing, text-align, text-transform, visibility, cursor

Not inherited (must be explicitly set on each element):

  • margin, padding, border, background, display, position, width, height, opacity
/* Force inheritance */
.child { color: inherit; }
.child { font-size: inherit; }

/* Reset inheritance */
.child { all: initial; } /* Resets EVERY property to its initial value */
.child { all: unset; } /* Resets: inherited properties → inherit, others → initial */
.child { all: revert; } /* Resets to browser stylesheet value */

2. CSS Entities (Unicode Characters in CSS)

CSS content property (used in ::before / ::after) accepts Unicode character codes. Format: \XXXX (backslash + 4–6 hex digits).

Commonly Used Entities

CharacterSymbolCSS CodeHTML Entity
Copyright©\00A9&copy;
Registered®\00AE&reg;
Trademark\2122&trade;
Checkmark\2713&#10003;
Heavy Check\2714&#10004;
Cross / ✗\2717&#10007;
Arrow right\2192&rarr;
Arrow left\2190&larr;
Arrow up\2191&uarr;
Double arrow\21D2&rArr;
Bullet\2022&bull;
Em dash\2014&mdash;
En dash\2013&ndash;
Ellipsis\2026&hellip;
Heart\2665&hearts;
Star\2605&#9733;
Open quote"\201C&ldquo;
Close quote"\201D&rdquo;
Non-breaking space(space)\00A0&nbsp;

Usage Examples

/* Automatic checkmarks for a feature list */
.feature-list li::before {
content: "\2713 "; /* ✓ + double-space */
color: var(--color-success);
font-weight: 700;
}

/* Arrow decorators on links */
.read-more::after { content: " \2192"; } /* Read more → */

/* Quote decorations */
blockquote::before {
content: "\201C"; /* Opening " */
font-family: Georgia, serif;
font-size: 5rem;
color: var(--color-primary);
}

/* Copyright in footer (dynamic, always current) */
.copyright::before { content: "\00A9 " attr(data-year) " "; }

3. The CSS attr() Function for Dynamic Content

/* Read attribute directly into content */
[data-label]::before { content: attr(data-label) ": "; font-weight: bold; }
[data-tooltip]::after { content: attr(data-tooltip); }
[href]::after { content: " (" attr(href) ")"; } /* Print URLs in printed pages */