Starting with CSS

Faruk Ateş provides a set of CSS rules to use as a starting point in Starting with CSS: revisited.

Why reset the margins and padding of specific element types instead of using the universal selector (*) to set everything to zero? Two reasons:

  1. Some browsers have default values for the margin and padding of form elements. Setting them to zero is not always a good idea.
  2. Since the universal selector matches every element in the document tree, it can slow things down.

Those are valid enough reasons, and I’ve started using a set of starting rules similar to those in Faruk’s example.

  • September 6, 2005
  • Comments closed
  • Posted in

Comments

1. September 7, 2005 by Robert Nyman

Faruk and I had some interesting discussions about this while, and after, he put his article together.

I'm all for it, but I'm also still interested in the actual slowing down effect the universal selector would have in a web browser. Are there any benchmark tests?

Why I'm asking is since high-profile CSS gurus (people like Eric Meyer) use the universal selector, and they, if any, should be aware of all possible side effects.

2. September 7, 2005 by Stuart Cruickshank

Noooo! The star selector has been the foundation of my CSS for some time! :)

I also like to see some testing performed on the 'slowing down effect'. I'd like to know whether or not the difference is negligible before I begin recoding. :)

3. September 9, 2005 by Faruk Ates

Stuart,

Developers of browsers have said they can see a slow down, but so far, I don't think anyone has made test cases of websites where there is a noticeable difference. However, there is still the form control element issue that you get from using * {}, as well as the fact that it's just not Best Practice to do that in the first place :-)

Sorry, comments are closed for this post.

Information, sponsorship, and externals

Subscribe

SidebarAds

Looking for web hosting?

Try DreamHost!

Use the promo code 456BEREASTREET3 to save USD 20 when you sign up!

Favourites, here and elsewhere

Affiliation

  • NetRelations
  • Kaffesnobben
  • Dagens recept
  • 9rules network member

Support this site

Show your support by buying a book or two from SitePoint or getting me something from my Amazon Wish List.