Sunday, July 30, 2006

CSS Inheritance Rules

Web development has a number of technolgies that can be used to render a web page. Here's the most important one's for me:
  • HTML
  • CSS
  • Javascript and DHTML
  • Ajax (Using Javascript to make server requests and update portions of the page).
  • Some scripting language - JSP, XSLT, ASP.Net, PHP
  • Flash
CSS is a very important peice in this list of technologies to master, but one most front-end developers think is simple and one that can be ignored or cut-and-pasted. I have a couple interview questions that I ask about CSS and as yet, no one has been able to answer them correctly and confidently. Developers tend to "get by" with css. This is often true with javascript, too.

I mainly want to know if the interviewee knows how cascading works in CSS. Specifically, I ask:
"Can you give me the formula for determining how a style rule is applied to an element when there are multiple rules that could apply?"

Or in CSS vernacular -

"How do you calculate a selectors specificity?" The answer is here

This isn't critical to being hired, but understanding the algorithms used by browsers to handle rule conflicts in CSS will only help your web development and shows you have a handle on this area of web development. Of course, using CSS in a practical way requires a deeper knowledge of the actual declaration properties that can be applied to the HTML elements. This just comes with time and experience.

0 comments:

Post a Comment