logoalt Hacker News

lmmlast Monday at 12:27 AM1 replyview on HN

> Cascading Style Sheets recently and I think it's the missing piece we've been looking for. It lets you declaratively specify layout in a composable, hierarchical system based on something called the Document Object Model in a way that minimizes both clientside and serverside processing, based on these things called "stylesheets"

I tried that and it was an absolute nightmare. There was no way to tell where a given style is used from, or even if it's used at all, and if the DOM hierarchy changes then your styles all change randomly (with, again, no way to tell what changed or where or why). Also "minimizes clientside processing" is a myth, I don't know what the implementation is but it ends up being slower and heavier than normal. Who ever thought this was a good idea?


Replies

skydhashlast Monday at 1:09 AM

> There was no way to tell where a given style is used from, or even if it's used at all

It's pretty easy. Open the inspector, select an element and you will find all the styles that apply. If you didn't try to be fancy and use weird build tools, you will also get the name of the file and the line number (and maybe navigation to the line itself). In Firefox, there's even a live editor for the selected element and the CSS file.

> if the DOM hierarchy changes then your styles all change randomly

Also styles are semantics like:

- The default appearance of links should be: ...

- All links in the article section should also be: ...

- The links inside a blockquote should also be: ...

- If a link has a class 'popup' it should be: ...

- The link identified as 'login' should be: ...

There's a section on MDN about how to ensure those rules are applied in the wanted order[1].

This way, your styles shouldn't need updates that often unless you change the semantics of your DOM.

[1]: https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Casc...

show 2 replies