tags:

views:

434

answers:

5

What kind of language is CSS?

My first inclination was to call it a markup language... but it doesn't really fit the mold.

Edit:

A markup language is a system for annotating a text in a way which is syntactically distinguishable from that text. -wikipedia

CSS uses various selectors to apply properties to elements within HTML, a markup language

+2  A: 

CSS is most definitely a language:

Wikipedia refers to css as a 'style sheet language'

http://en.wikipedia.org/wiki/Style_sheet_language

Also from W3C who developed CSS: (comparing XSL and CSS)

The unique features are that CSS can be used to style HTML & XML documents. XSL, on the other hand, is able to transform documents. For example, XSL can be used to transform XML data into HTML/CSS documents on the Web server. This way, the two languages complement each other and can be used together.

Both languages can be used to style XML documents.

As you can see from the second sentence W3C refers to CSS as a language.

http://www.w3.org/Style/

And the next quote again from the same article:

The fact that W3C has developed XSL in addition to CSS has caused some confusion. Why develop a second style sheet language when implementors haven't even finished the first one? The answer can be found in the table below:

DKinzer
Yes, I saw that. The article only really gives one example of what "stylesheet" language is... and that's CSS.
Derek Adair
Yes, I also thought that was weird. But then it may be the only one of it's kind so far.
DKinzer
+15  A: 

I would say it is a domain-specific declarative language.

Nick
This might be true, but it's hardly a useful definition; as most applications of XML, are, in essence, DSDLs, as are a lot of other things.
Williham Totland
DSDL definitions become useful when you know what the domain is. :)
Vivin Paliath
@Vivian Paliath: Yes; but the definition *of* something as a DSDL is not particularly so.
Williham Totland
It is a broad category but I am not sure you can get any more specific other than saying it is a stylesheet language which is a bit like saying HTML is a hyper text markup language
Nick
+6  A: 

CSS is not really a language, per se; it is more of a syntax for describing configuration directives.

In fact, it is neither of these things; CSS is a description of a number of tokens and their visual meanings; .css files contain these tokens structured in manner allowing a computer to parse them. CSS declarations can take the form of name="value" declarations in SVG documents; and the .css file structure could just as easily be employed to, say, contain unit descriptions in a particularly absurd iteration of FreeCiv.

Wikipedias definition of it as a Style sheet language seems like a bit of a forced definition of a generalization of a singularly existing phenomenon; and it should be clear that it is not in any way a markup language, as it doesn't actually, by itself, mark anything up.

Williham Totland
I completely agree that Wikipedia's definition is a bit forced.
Derek Adair
According to W3C, CSS is definitely a language and there are define at least three that fall into this category of languages: css, xpath, xslt - http://www.w3.org/Style/
DKinzer
Why isn't CSS a language? Clearly, it is not a programming language, but it has its own grammar, so it /is/ formal language.
el.pescado
@el.pescado: Well, obviously. But I would think that qualifying the word language with a "programming" just seems so unnecessary on SO.
Williham Totland
Writing web pages with HTML and CSS is not programming, so strictly speaking it is off-topic here, though it seems to be tolerated.
starblue
+5  A: 

Syntactically, CSS is a mix of two languages: the language of selectors, which is a pattern-matching one, like regexps or xpath, and the language of properties, which can be classified as "procedural-declarative", because properties are essentially assignment operators. At a subjective level, css clearly qualifies as ugly mess, like pretty much every other fruit of collective efforts on the field of language design ("a camel is a horse designed by committee").

stereofrog
...and C++ is an octopus made by nailing extra legs onto a dog.
Michael Borgwardt
@Michael: That is actually a pretty accurate description of C++
BlueRaja - Danny Pflughoeft
I'm not sure I'd call any part of CSS "procedural" unless you're talking about expressions, but I'm glad somebody agrees that CSS is an ugly mess. When, in a *formatting* language, the best way to center something is to give it a `margin:auto;` property (and an explicit width), you know something went wrong.
tloflin
A: 

This is a good question, "How does one define a styling language?"

With limited symantic knowledge at this time, I agree with Nick's answer: "Declaritive Language."

FreshCode