DEV Community

Discussion on: Style beautiful web pages without writing any CSS. Using W3.CSS.

Collapse
 
lazarljubenovic profile image
Lazar Ljubenović

No. From the WHATWG HTML spec, § 3.2.6 (emphasis mine):

There are no additional restrictions on the tokens authors can use in the class attribute, but authors are encouraged to use values that describe the nature of the content, rather than values that describe the desired presentation of the content.

It doesn't any sense for HTML, which is all about document semantics, to announce that an element is of type "padding-small". Use a class name to categorize an element such as "important-item", "feed-item", etc.

The article claims that you're not writing any CSS. Why in the world would you do class="padding-small" when you can do style="padding: var(--small)", which precisely describes what you want, and is a standardizes way of doing things?

Everyone goes bananas over inline styles, repeating a mantra they've read somewhere about how "it's bad practice", "anti-pattern", and then they splash a class="margin-top-medium". Totally not inlining styles. Nope, not at all.