Sharing our knowledge
Nothing is more useful than the information you've been looking for. Our blogs communicate our recent findings and expertise within our skillset.
Please select a blog from the menu.
Nothing is more useful than the information you've been looking for. Our blogs communicate our recent findings and expertise within our skillset.
Please select a blog from the menu.
Written on Wed, 01 Jul 2009
By Amy Varga
Amy Varga takes a look at two recent developments in CSS namely the concept of object oriented CSS and the semantic naming of classes and ID's, finally she makes some suggestions of how to best write CSS.
During a recent contract I came face to face with ‘the CSS nightmare’. Huge websites with multiple style sheets using complex specificity to assign styles to elements. The result was inconsistent styles across various sections of the website, lengthy style sheets and more development hours then was necessary.
Realising there was a problem I needed to find a solution.
Object oriented CSS works in a similar way to Object Oriented Programming (OOP):
Inheritance is the means by which, in the absence of any specific declarations applied by the CSS cascade, a property value of an element is obtained from its parent element. Inheritance is a mechanism that’s separate from the cascade: inheritance applies to the DOM (Document Object Model) tree.
The cascade deals with the style sheet rules. The cascade combines the importance, origin, specificity, and source order of the applicable style declarations to determine exactly—and without conflict—which declaration should be applied to any given element.
The concept of object oriented CSS is noteworthy. The principles of the reuse of styles and inheritance / cascade are fundamental in creating an optimal CSS.
The semantic naming of classes and IDs is a controversial one. This concept requires that all classes and IDs be named according to their meaning or role within a web page. Unfortunately only web developers, designers and author benefit from semantically named classes and IDs. Web page browsers, screen readers and search engines do not use classes or ID’s to gain more information about a web page.
The benefits to web developers, designers and authors are:
The disadvantage of semantically naming classes and IDs is that it in some cases there is no logic in naming it semantically. Yahoo Grids and Blueprint CSS are both CSS frameworks based on grids and both frameworks name their classes based on their presentation. For example, Blueprint’s <div class=”span-24”> relates to a <div> that spans the entire 960px over 24 columns.
The semantic naming of classes and IDs have their benefits and should be encouraged however, when there is no logical reason to name an element semantically when a name relating to presentation may be more appropriate. For example, a rounded corner <span> may be named roundedCornerTopLeft.
At Tue 1st Dec 2009 07:26:35, outrapunsanny (streamtvonline@gmail.com) said:
nice answers i like it
At Tue 29th Dec 2009 09:42:05, buy viagra (jhon.lamad@gmail.com) said:
Does anyone know where I can find free online grant applications?
At Wed 30th Dec 2009 18:53:58, viagra online (jhon.lamad@gmail.com) said:
Does anyone know where I can find free online grant applications?
At Wed 6th Jan 2010 02:35:31, Kneemoirory (alvinwaters9986627@gmail.com) said:
nice answers i like it
At Fri 15th Jan 2010 09:32:54, Generic Viagra (las1dk23@mail.ru) said:
I wish not concur on it. I over polite post. Expressly the title-deed attracted me to read the whole story.
At Tue 19th Jan 2010 06:12:04, WP Themes (jonala234l@gawab.com) said:
Nice fill someone in on and this enter helped me alot in my college assignement. Say thank you you for your information.
At Mon 15th Feb 2010 16:56:35, amazon coupon (wi.set.imic@gmail.com) said:
quite interesting article. I would love to follow you on twitter.
At Fri 19th Feb 2010 21:11:01, Brice Marshall (regnardy@yandex.ru) said:
Do you have copy writer for so good articles? If so please give me contacts, because this really rocks! :)
Email:info@absoluteorange.com
Tel:+44 (0)1462 627 971
Mobile:+44 (0)75322 75361
Skype:amy.varga