How do I apply a CSS to the whole page?

O

OM

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.

Thanks.


OM
 
D

David Dorward

OM said:
It's probably really simple, but how do I apply a CSS to an entire page?

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

body {
font-family: serif;
}

might be what you are looking for.
 
S

SeeSchloss

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
tags.
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 :

a.external
{
text-decoration:underline;
other declarations;
}

More generally, you must define styles in the sheet this way :
tagname.class
{
property:value;
}

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

Phrederik

OM said:
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?

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...

<style>
body { font-family: serif; }
someattribute { someProperty: someStyleValue; someProperty:
someStyleValue; }
</style>

.... 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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,260
Messages
2,571,039
Members
48,768
Latest member
first4landlord

Latest Threads

Top