One Rule To Rule Them All

Here's a quick tip for anyone wanting to easily apply a rule to all of the elements within a design. Just use

* {
whatever: whatever;
}

and you can target everything within your design, as the * selector is universal.

But what's a practical use for this?

Well, anyone who uses CSS knows how annoying it can be to try and get all of the margin and padding correct, and make it look the same across different browsers.

This can be especially tricky when you consider that, before you've even written one line of code, your browser is applying its own default CSS styles. This is because all browsers have their own in-built style sheets which, whilst they may be quite basic, will affect your design.

So a simple tip is to clear out any external margin and padding before you start. To do this just use the following code at the top of your style sheet:

* {
margin: 0;
padding: 0;
}

This zeros out the margin and padding on all elements and gives a nice clean starting point, making it (hopefully;) ) easier to diagnose any future problems.

1 comment

1
GuestMay 19th 2007 @ 02:13PM

Hello
So true. And not onyl for drupal, but for any site...

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options