Basic questions on CSS

This is the first post written in the form of a FAQ list that appears on this blog, so I'm going to be as clear as possible. Many of these questions come from my long permanence on several mailing lists and forums whose main topic is CSS. I think that every single question can actually have multiple answers and for that reason I want to summarize as many answers as possible.

Is CSS a programming language?

No. CSS is a style sheet language written for being applied to any web document on the web. You don't have to be a programmer to use and write CSS. All you need is a text editor and a web document to stylize. And, of course, one or more browsers for testing your code.

Is it useful to read the CSS specifications?

Only if you're in an intermediate or advanced level of your CSS training. Specifications are useful when you want to make something clear to yourself, for example in the case of some obscure behavior of browsers. In all the other cases, all you need are some good examples and tutorials available on the web by running a simple search on Google.

What browsers should I use to test my code?

The latest versions of Internet Explorer, Safari, Chrome, Firefox and Opera. If you have particular needs for supporting obsolete browsers like IE 6 and 7, then it's better to use standalone versions of these browsers so that you can have them on the same machine. Anyway, you don't need to get mad about browsers. The only thing to keep in mind is that if a browser doesn't support a particular feature, then your document will appear in a slightly different way, nothing more. This is called graceful degradation.

Is it important to comment my CSS code?

It's a basic requirement to spare some time instead of performing desperate searches through hundreds lines of code. CSS comments can actually help you to keep your code organized in blocks, so you can easily run a text search by using comment blocks as a reference. Further, if you have inserted a CSS hack or a new solution into your code, using comments is the only way to outline it.

Should I validate my CSS?

Only if you have to, for example when something doesn't work and you're not sure if it depends on a syntax error or something else. Another use case for validation is when you have to fulfill some legal requirements that have validation as a strict must. In all other cases except syntax, parsing and legal stuff, validation is completely useless.

May I use vendor extensions?

As said above, if your CSS must pass validation, then you can't use them. In all other cases, use them at will. Their impact on the CSS parsing of non-supporting browsers is absolutely negligible.

What are validation profiles?

The W3C CSS validator allows you to attach the string &profile=version to the URL you use to validate your CSS file, where version is the profile used for validating your code. Possible values are css1, css2, css3. For further information, check out the documentation.

This entry was posted in by Gabriele Romanato. Bookmark the permalink.

Leave a Reply

Note: Only a member of this blog may post a comment.