Search code examples
cssw3c

Why w3c created the property 'style' to determine all properties?


I would like to know why they created the property style for all properties instead of create a new property for each one? Let me explain better, today we use this:

<p style="color:blue; background-color:red"></p>

I would like to know why they didn't do like that:

<p color="blue" background_color="red"></p>

Is there something in any w3c document telling it?


Solution

  • Thanks to the style attribute, the development of new CSS properties doesn’t require an update to the HTML specifications.

    If we’d have a separate HTML attribute for each CSS property, all these attributes would have to be defined in the HTML spec. So whenever a new CSS property is defined, all HTML specs would have to be updated. Otherwise this new CSS couldn’t be used in older HTML versions (validly).

    In the same sense HTML doesn’t define graphic formats (like PNG) or codecs for audio/video, or the content of math or svg.

    So CSS and HTML developers can work separately from one another, as long as they respect the interface they agreed on: the style attribute (and the other ways to add CSS for HTML).

    Another reason: It would be possible that other styling methods come up in the future, not compatible to CSS. Now when everyone would get their own attributes, that would become a total mess.