0

There is a new value in CSS3 called 'initial', it will reset the prop's value to the browser's default.

The spec here: https://developer.mozilla.org/en-US/docs/Web/CSS/initial

But in most times, a website/webpage often have a reset.css or normalize.css file apply to the site/page.

So in most cases, I want the prop which set to 'initial' to be the reset.css or normalize.css's value but not the browser's default, how to solve the conflict between those two?

Xieranmaya
  • 792
  • 10
  • 11
  • 1
    Why not just use the same value as in the `reset.css` then? It's a constant, so there are no issues with changing it. Can you show a specific example where you have a problem with this? – Bergi Feb 13 '14 at 02:04
  • most times the developer can not remember the value in the reset.css, is it? – Xieranmaya Feb 13 '14 at 03:33

1 Answers1

3

There is a new value in CSS3 called 'initial', it will reset the prop's value to the browser's default.

That's where most people are mistaken (even I got it wrong once). The initial value is not the same thing as the browser's default value.

A browser default is set by the browser in its default stylesheet.

The initial value of a property is the default that is stated in the spec. The initial value is usually the same regardless of what element you apply the property to; it's the browser that decides whether it should apply a different value to different elements by default.

For example, the initial value of display is inline — many HTML elements default to display: block, but setting display: initial will turn them into inline elements, not block elements.

Even the document you link to itself links to another document defining the term "initial value":

The initial value given in the summary of the definition of each CSS property has different meaning for inherited and non-inherited properties.

With all that said, there is currently no way using CSS to reset a property to either a browser's default or an arbitrary level in the cascade (e.g. normalize.css or a reset stylesheet).

Community
  • 1
  • 1
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
  • This is a great answer and should be accepted. There is now a postcss plugin you can use to leverage some aspects of `initial` https://github.com/maximkoretskiy/postcss-initial – Jed Richards Jan 26 '16 at 10:46