Hello readers,
Welcome to third and final part of my CSS primer.
Continuing from previous post ‘CSS Steady’ now I’ll tell you something about polishing the CSS. Following text will help in decision making during CSS coding.
ID vs Class Vs Tag Vs Pseudo selectors:
All CSS developers know this fact there are verity of CSS selectors, CSS rules can be applied by using any one or combination of available selectors. We can apply CSS rules by inline CSS as value of style attribute of HTML tags or internal CSS by using style tag, or we can go for external style sheet. Inline CSS is bad and must be avoided. Inline style declarations should be limited to for some run time CSS manipulation only.
In summery using external CSS is preferred way, Its success depends on use of inline or internal CSS, since in effectiveness of application of CSS rules hierarchy, inline CSS is topmost level after that comes internal CSS and external CSS comes bellow them.
Same way ‘id’ is above ‘class’ in hierarchy of effectiveness of CSS selectors. Id can’t be used more than once in a page (its preferred to use one id for same element throughout application not only withing page).
Rigid element’s CSS should be served by using ‘id’ CSS selectors, which will be used only once e.g. header, footer etc. Elements with dynamic nature having shared or inherited property with possible multiple occurrence need fetch CSS rules by ‘class’ selectors.
Use of ‘tag’ selectors can be decided by doing some research on default look and feel of elements of application. psudo CSS selectors can be used if backward compatibility with older browsers not needed.
Inheritance playes a great role inĀ in this that’s why planning is uttermost important. we should always keep in mind we are just contributing in development of some application which might have multiple developers hence coding must stick to requirements and standards of application so any one can understand and edit code of each other.
Modular CSS needs to be developed and all inherited properties needs to commented within CSS declaration so one don’t repeat same CSS again and selectors needs to named by some naming convention (e.g. prefixing every declaration by module).
Modules needs to be devised in such way so it remain plug and play if plugged in different application.
Resources:
following are some useful resources which might play great role to make a good CSS developer out of you.
- Make your markup clean
- Don’t fear to java script RIA is future. Jquery might be good place to start (and possibly end of search).
- Keep a tab on latest, fresh and trust worthy tips, tricks, trends, news etc related to web development.
- Get benefit and give benefit by being active part of revolution in web development. Join the wiki maintained by web developers for web developer from Google.
- Know more about standards, stick to them and force them upon you, make web development your passion and web standards your religion.
Above links are ocean on themselves and they carry more waves within if you want to explore more.
But my point is practice them, Its more important.
Ok guys hope you have enjoyed the article and will take benefit out of it.
Happy Web Development
Cheers
