Live data from Hacker News

Idea: When (if) statements in CSS

hastebin.com

21–24 of 24 posts

Re: Idea: When (if) statements in CSS

#21
Ideologic errors apart (which are epic) the feature you propose will anyway be not usable.

In a `@if` what does `li` means related to the `li` inside the body? Absolutely nothing.

What could seriously be interesting instead is a property value selector similar to attribute selector. Something similar to `[@color != red]`

Re: Idea: When (if) statements in CSS

#22
post #12

You can already do things like this with stylus ( http://learnboost.github.com/stylus/ ). As far as I can see, if you are thinking at this level with css you should be using a preprocessor for sure. I can't remember the last project I used vanilla css in. Here's a totally silly example, but you can see the power: color-if-hidden(color) if @display == none color: color .hello display: none color-if-hidden(red)

It's true, but you're not considering cascade rules, of course. How do you know that another selector has `display: inline`ed that element?

EDIT: typo

Re: Idea: When (if) statements in CSS

#24
post #5

This will allow never ending loops (two of these can @when each other) - css is not an imperative language that works from top to bottom, it's more of a state language where certain items override other. If you add this, the language will become turing complete, and then you'll have people disabling css just like they disable javascript. If you want this, you'll need to find a syntax that makes it impossible for css…

I don't really see why this syntax can't work as CSS does today? The last style with equal "weight". This idea can be implemented with the same idea.

The weight rules applies to any specific element on the page, but this is different.

You can make one rule depend on another, and then that rules depends on the first. This can cause a loop.

You could ignore one I guess, but how do you decide which? Do you use css order? Do you use the order of the page? What is there is an inline style? What is two elements have the style?

It's better not to make a syntax that can get you into trouble like that.

Post reply on HN