liveBook · Manning

Vendor prefix

As explained in Tiny CSS Projects

A vendor-prefixed property is an experimental or nonstandard CSS property identified by a browser-specific prefix.

A vendor prefix marks a browser-specific CSS property or selector. Prefixes were historically used for experimental features, whose behavior might be incomplete, nonstandard, or subject to change. Common prefixes include `-webkit-` and `-moz-`. section 3.6.1

Restyling a progress bar

A `<progress>` element comes with browser styling. Adding `background: pink` does not simply recolor it: the control changes appearance and its accent color is lost. Reset the default appearance with `-webkit-appearance: none; -moz-appearance: none; appearance: none;`, then style the control’s parts. In WebKit-based browsers, `::-webkit-progress-value` targets the filled portion; Firefox uses `::-moz-progress-bar` for that purpose. section 3.6.1 section 3.6.2 section 3.6.3

Listing 3.16 Updated progress rule
progress {
  height: 24px;
  width: 100%;
  border-radius: 20px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

The progress rule places both prefixed appearance declarations before the unprefixed declaration. section 3.6.1

Test each browser rather than assuming prefixed selectors behave alike. Combining the Firefox and WebKit progress selectors in one rule styles Firefox but breaks Chrome; separate, identical rules work around the problem. Prefixed features remain experimental, so these styles may need revisiting. section 3.6.3

Prefixes also appear in image-filled heading text. `background-clip: text` needs `-webkit-background-clip` for the specified WebKit-based browsers, while `text-fill-color` needs prefixed declarations. Keep a visible `color` fallback if the image or experimental styling fails, and put prefixed properties before an available unprefixed version. Do not add prefixes automatically: major browsers no longer need them for gradients. section 5.3.2 section 3.6.2

How Tiny CSS Projects covers it

How deep it goes
Defines prefixes and works through browser-specific declarations and a selector failure, while warning that experimental implementations can change.
Examples
Shows a progress bar styled for Chrome and Firefox, plus a heading whose image is clipped to its letters.
What it assumes
Starts with an HTML progress element and explains its appearance reset and browser-specific styling as needed.
What you can do after
Build it from scratch by resetting a progress control and applying separate prefixed rules where browsers require them.
How it connects
Connects vendor prefixes to appearance, pseudo-elements, background-clip, text-fill-color, and browser feature flags.

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.