About

Thoughts on Design is a blog on web design and front-end coding. Served up monthly-ish by Jamis Charles.

Search

You are currently browsing the archives for the CSS category.

Categories

Archive for the ‘CSS’ Category

How to write a CSS rule that will affect every element:


25 of October2007

Sometimes there’s a need to reset all of the margins on a page, or you simply want something specifically applied to each element without having to count on inheritances to do the job. The solution: “*” or “universal selector”. This seems familiar from other languages right? Well, it should be. It simply means “everything” in a selected area.

The following will apply a gray background to every element on a page.

* {
    background-color: #eee;
}

What if you want to get more specific?
With this code, everything within the div with the id=”wrapper” will have a gray background.

div#wrapper * {
    background-color: #eee;
}

Obviously any properties can be used here. Enjoy.

Add an external CSS Stylesheet to your page


17 of May2007

Adding an external stylesheet to your page is preferable to using inline CSS (or just pasting it into your head code). Instead use and external file name “*.css”. To link to the file, write the code below into your head code:

<link rel="stylesheet" type="text/css" href="nameofYourCSSFile.css" />