How do I apply a CSS to the whole page?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
It's probably really simple, but how do I apply a CSS to an entire page?
I've only just recently learned about CSS... so I'm a bit lost.

At the moment, I'm having to apply to every bit of text that I write.
Can't I just add a bit of code to make the style apply to the whole document
or something?

Any help would be appreciated.



Re: How do I apply a CSS to the whole page?

OM wrote:

Quoted text here. Click to load it

Depending on what exactly you are trying to achieve, something like:

body {
  font-family: serif;

might be what you are looking for.

David Dorward                              /

Re: How do I apply a CSS to the whole page?

Well maybe you should try to find a tutorial on internet to learn more
about css.

Seeing  what you said, I guess you using style="property:value;" in you
If you want to apply the tags to the whole document, you can either add
a reference to an external stylesheet : <link rel="stylesheet"
type="text/css" href="style.css" /> where style.css if the name of the
file where your styles are saved (between <head> and </head>) or define
it at the beginning of your document (but I can't tell you how to do it
and anyway I think that external stylesheets are better).

This way if you want for example a special formating for all your
external links, add class="external" in your links (<a href="address"
class="external">...</a>) and in you stylesheet, add :

  other declarations;

More generally, you must define styles in the sheet this way :

I'm not sure this is well explained, I think you should search a good
tutorial instead :-)

Quoted text here. Click to load it

Re: How do I apply a CSS to the whole page?

Quoted text here. Click to load it

It looks like the answers may be missing an important point.

If you want your STYLEs to apply to the whole page put the following inside
of your HEAD tags...

    body { font-family: serif; }
    someattribute { someProperty: someStyleValue;  someProperty:
someStyleValue; }

... and the attributes will all have their style applied on the whole page.

You can also make a CSS file with your styles in it. The file looks the same
as what would go inside of the STYLE tags. Then you'd add the following to
any page that you want that style file to apply to...

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

...AND, if you are going to have pages for printing, you might want to make
a custom STYLEs CSS file just for printing. Include it as:

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

Hope this helps a bit!

Site Timeline