

Ask HN: What do you think of the anti-CSS debate? - donjh

I&#x27;ve been hearing more and more about the concept of applying inline styles through JavaScript as opposed to using CSS. There&#x27;s been an article floating around regarding the idea, too (https:&#x2F;&#x2F;css-tricks.com&#x2F;the-debate-around-do-we-even-need-css-anymore&#x2F;). What&#x27;s your take?
======
pixellab
As someone who writes CSS frameworks for a living, I don't know if I could
ever give up the powerful globalness of the "c" (cascading.) Though, I do find
myself writing more and more inline styles for elements that are specific to a
block or page to avoid bloating the framework. I'm thinking a blended approach
is in my future.

------
bjourne
I think he is glossing over CSS main selling point which is a separation of
concerns. Essentially, you can code a web-site unstyled and then let an
independent 3rd party write a style sheet for it.

He is saying that you would have a 'style.js' performing the task, but he is
not specifying exactly how that file would replace the 'style.css'. A designer
writing the 'style.js' key-value pair seems implausible as does converting a
designer-created 'style.css' to 'style.js'.

------
jdeisenberg
Random thoughts: As far as I understand it, CSS is declarative. JavaScript,
not so much. The declarative aspect of CSS is nice; you just specify what you
want and CSS handles everything else for you.

I am also idly wondering how this would all work out in "HTML and CSS as
s-expressions" à la Ŝablono
[https://github.com/r0man/sablono](https://github.com/r0man/sablono)

------
seaneking
To me this is a bit of a 'baby with the bathwater' scenario. CSS has problems
(particularly lack of namespacing), but I don't think the solution is to just
pack up shop on stylesheets and port everything to js. If the argument is
about logic, then postCSS and manipulating the CSSOM are cleaner approaches
IMO. And with web components the modularity concern is pretty much entirely
mitigated. There's definitely an argument to be made about javascript's role
styling, but I think it should be complimentary alongside the purely
declarative stylesheet.

------
n17r4m
Personally, I think there is a lot of magic yet to be discovered in
dynamically manipulating the CSSOM (CSS Object Model).

Case study: If trying to manipulate some ~100 inline-block elements into a
grid, with dynamic (say, zoomable + pannable + screen size dependant) width,
height and offset. It makes way more sense to programmatically modify the
stylesheet using the CSSOM API with fast calculated values, rather than
applying unique styles to each of those 100 elements in the DOM, O(1) vs O(n)
- yes?

------
vezzy-fnord
Ironically enough, Netscape proposed a JavaScript Style Sheets specification
back in 1996 to replace CSS, but was rejected for being too complicated:
[https://en.wikipedia.org/wiki/JavaScript_Style_Sheets](https://en.wikipedia.org/wiki/JavaScript_Style_Sheets)

------
helpmeimpoor
I hope html and css bending become one language is there any language like
that to make a webpage?

~~~
philippnagel
Perhaps [http://elm-lang.org](http://elm-lang.org) ?

