Recommendation · CSS

Cascading Style Sheets

4 properties, 7 selectors, 2 types defined by this specification, 12 of them known to at least one browser (the others are badged Not in any browser yet).

Each feature in detail

page-break-after

Property Deprecated

MDN The page-break-after CSS property adjusts page breaks after the current element.

Live preview Example from MDN
.box {
  border: solid #5b6dcd 5px;
  background-color: #5b6dcd;
  margin: 10px 0;
  padding: 5px;
}

#example-element {
  border: solid 5px #ffc129;
  background-color: #ffc129;
  color: black;
}

Syntax

auto | always | avoid | left | right | inherit

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
block-level elements (but see text)
Inherited
no
Percentages
N/A
Computed value
as specified
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting page-break-after
Chrome 1
Edge 12
Firefox 1
Safari 1.2
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

page-break-before

Property Deprecated

MDN The page-break-before CSS property adjusts page breaks before the current element.

Live preview Example from MDN
.box {
  border: solid #5b6dcd 5px;
  background-color: #5b6dcd;
  margin: 10px 0;
  padding: 5px;
}

#example-element {
  border: solid 5px #ffc129;
  background-color: #ffc129;
  color: black;
}

Syntax

auto | always | avoid | left | right | inherit

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
block-level elements (but see text)
Inherited
no
Percentages
N/A
Computed value
as specified
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting page-break-before
Chrome 1
Edge 12
Firefox 1
Safari 1.2
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

page-break-inside

Property Deprecated

MDN The page-break-inside CSS property adjusts page breaks inside the current element.

Live preview Example from MDN
.box {
  border: solid #5b6dcd 5px;
  background-color: #5b6dcd;
  margin: 10px 0;
  padding: 5px;
}

#example-element {
  border: solid 5px #ffc129;
  background-color: #ffc129;
  color: black;
}

@media print {
  #example-element {
    height: 25cm;
  }
}

Syntax

avoid | auto | inherit

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
block-level elements (but see text)
Inherited
no
Percentages
N/A
Computed value
as specified
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting page-break-inside
Chrome 1
Edge 12
Firefox 19
Safari 1.3
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

z-index

Property Baseline: widely availablesince January 2018

MDN The z-index CSS property sets the z-order of a positioned element and its descendants or flex and grid items. Overlapping elements with a larger z-index cover those with a smaller one.

Live preview Example from MDN
#example-element {
  top: 15px;
  left: 15px;
  width: 180px;
  height: 230px;
  position: absolute;
  /* center the text so it is visible even when z-index is set to auto */
  line-height: 215px;
  font-family: monospace;
  background-color: #fcfbe5;
  border: solid 5px #e3e0a1;
  z-index: auto;
  color: black;
}

.container {
  display: inline-block;
  width: 250px;
  position: relative;
}

.block {
  width: 150px;
  height: 50px;
  position: absolute;
  font-family: monospace;
  color: black;
}

.blue {
  background-color: #e5e8fc;
  border: solid 5px #112382;
  /* move text to the bottom of the box */
  line-height: 55px;
}

.red {
  background-color: #fce5e7;
  border: solid 5px #e3a1a7;
}

.position1 {
  top: 0;
  left: 0;
  z-index: 6;
}

.position2 {
  top: 30px;
  left: 30px;
  z-index: 4;
}

.position3 {
  top: 60px;
  left: 60px;
  z-index: 2;
}

.position4 {
  top: 150px;
  left: 0;
  z-index: auto;
}

.position5 {
  top: 180px;
  left: 30px;
  z-index: auto;
}

.position6 {
  top: 210px;
  left: 60px;
  z-index: auto;
}

Syntax

auto | <integer> | inherit

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
positioned elements
Inherited
no
Percentages
N/A
Computed value
as specified
Canonical order
per grammar
Animation type
by computed value type

Browser support

First browser version supporting z-index
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

:after

Selector Baseline: widely availablesince January 2018

MDN In CSS, ::after creates a pseudo-element that is the last child of the selected element. It is often used to add cosmetic content to an element with the content property. It is inline by default.

Live preview Example from MDN
a::after {
  content: " (" attr(href) ")";
}

.dead-link {
  text-decoration: line-through;
}

.dead-link::after {
  content: url("https://developer.mozilla.org/shared-assets/images/examples/warning.svg");
  display: inline-block;
  width: 12px;
  height: 12px;
}

Syntax

:after

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :after
Chrome 1
Edge 12
Firefox 1.5
Safari 4
Chrome Android 18
Safari iOS 3.2

First version with support, from MDN browser-compat-data.

:before

Selector Baseline: widely availablesince January 2018

MDN In CSS, ::before creates a pseudo-element that is the first child of the selected element. It is often used to add cosmetic content to an element with the content property. It is inline by default.

Live preview Example from MDN
a {
  color: blue;
  text-decoration: none;
}

a::before {
  content: "🔗";
}

.local-link::before {
  content: url("https://developer.mozilla.org/shared-assets/images/examples/firefox-logo.svg");
  display: inline-block;
  width: 15px;
  height: 15px;
  margin-right: 5px;
}

Syntax

:before

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :before
Chrome 1
Edge 12
Firefox 1.5
Safari 4
Chrome Android 18
Safari iOS 3

First version with support, from MDN browser-compat-data.

:first

Selector Limited availability Modern CSS: Page selectors

Spec Authors may also specify style for the first page of a document with the :first pseudo-class:

MDN The :first CSS pseudo-class, used with the @page at-rule, represents the first page of a printed document. (See :first-child for general first element of a node.)

Live preview Example from MDN
@page :first {
  size: 8.5in 11in;
  margin-left: 3in;
  margin-top: 5in;
}

p {
  page-break-after: always;
  font: 1.2em sans-serif;
}

Syntax

:first

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :first
Chrome 18
Edge 12
Firefox 116
Safari 6
Chrome Android 18
Safari iOS 6

First version with support, from MDN browser-compat-data.

:first-letter

Selector Baseline: widely availablesince January 2018

MDN The ::first-letter CSS pseudo-element applies styles to the first letter of the first line of a block container, but only when not preceded by other content (such as images or inline tables).

Live preview Example from MDN
p::first-letter {
  font-size: 1.5rem;
  font-weight: bold;
  color: brown;
}

Syntax

:first-letter

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :first-letter
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

:first-line

Selector Baseline: widely availablesince January 2018

MDN The ::first-line CSS pseudo-element applies styles to the first line of a block container.

Live preview Example from MDN
p::first-line {
  font-size: 1.2rem;
  font-weight: bold;
  text-decoration: underline;
}

Syntax

:first-line

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :first-line
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

:left

Selector Limited availability Modern CSS: Page selectors

Spec All pages are automatically classified by user agents into either the :left or :right pseudo-class. Whether the first page of a document is :left or :right depends on the major writing direction of the root element. For example, the first page of a document with a left-to-right major writing direction would be a :right page, and the first page of a document with a right-to-left major writing direction would be a :left page. To explicitly force a document to begin printing on a left or right page, authors can insert a page break before the first generated box.

MDN The :left CSS pseudo-class, used with the @page at-rule, represents all left-hand pages of a printed document.

Syntax

:left

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :left
Chrome 6
Edge 12
Firefox No
Safari 5
Chrome Android 18
Safari iOS 4.2

First version with support, from MDN browser-compat-data.

:right

Selector Limited availability Modern CSS: Page selectors

Spec All pages are automatically classified by user agents into either the :left or :right pseudo-class. Whether the first page of a document is :left or :right depends on the major writing direction of the root element. For example, the first page of a document with a left-to-right major writing direction would be a :right page, and the first page of a document with a right-to-left major writing direction would be a :left page. To explicitly force a document to begin printing on a left or right page, authors can insert a page break before the first generated box.

MDN The :right CSS pseudo-class, used with the @page at-rule, represents all right-hand pages of a printed document.

Syntax

:right

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :right
Chrome 6
Edge 12
Firefox No
Safari 5
Chrome Android 18
Safari iOS 4.2

First version with support, from MDN browser-compat-data.

<generic-family>

Type Not in any browser yet

Spec In the example above, the last value is a generic family name. The following generic families are defined: serif (e.g., Times) sans-serif (e.g., Helvetica) cursive (e.g., Zapf-Chancery) fantasy (e.g., Western) monospace (e.g., Courier) Style sheet designers are encouraged to offer a generic font family as a last alternative. Generic font family names are keywords and must NOT be quoted.

MDN The <generic-family> CSS data type represents the keyword values for generic font families used in the font shorthand and font-family longhand properties. The <generic-family> represents one or more locally-installed fonts belonging to that category of fonts.

<shape>

Type Deprecated

Spec In CSS 2, the only valid <shape> value is: rect(<top>, <right>, <bottom>, <left>) where <top> and <bottom> specify offsets from the top border edge of the box, and <right>, and <left> specify offsets from the left border edge of the box. Authors should separate offset values with commas. User agents must support separation with commas, but may also support separation without commas (but not a combination), because a previous revision of this specification was ambiguous in this respect. <top>, <right>, <bottom>, and <left> may either have a <length> value or auto. Negative lengths are permitted. The value auto means that a given edge of the clipping region will be the same as the edge of the element’s generated border box (i.e., auto means the same as 0 for <top> and <left>, the same as the used value of the height plus the sum of vertical padding and border widths for <bottom>, and the same as the used value of the width plus the sum of the horizontal padding and border widths for <right>, such that four auto values result in the clipping region being the same as the element’s border box). When coordinates are rounded to pixel coordinates, care should be taken that no pixels remain visible when <left> and <right> have the same value (or <top> and <bottom> have the same value), and conversely that no pixels within the element’s border box remain hidden when these values are auto.

MDN The <shape> CSS data type defines the specific form (shape) of a region. The region represents the part of an element to which the clip property applies.

Syntax

rect(<top>, <right>, <bottom>, <left>)

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting <shape>
Chrome 1
Edge 12
Firefox 1
Safari 1.3
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.