Applying CSS
There are three ways to apply CSS to HTML.
In-line:
In-line styles are plonked straight into the HTML tags using the style attribute.
They look something like this:
<p style="color: red">text</p>
This will make that specific paragraph red.
But, if you remember, the best-practice approach is that the HTML should be a stand-alone, presentation free document, and so in-line styles should be avoided wherever possible.
Internal:
Embedded, or internal styles are used for the whole page. Inside the head tags, the style tags surround all of the styles for the page.
This would look something like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>CSS Example</title>
<style type="text/css">
p {
color: red;
}
a {
color: blue;
}
</style>
...
This will make all of the paragraphs in the page red and all of the links blue.
Similarly to the in-line styles, you should keep the HTML and the CSS files separate, and so we are left with our saviour…
External:
External styles are used for the whole, multiple-page website. There is a separate CSS file, which will simply look something like:
p {
color: red;
}
a {
color: blue;
}
If this file is saved as “web.css” then it can be linked to in the HTML like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>CSS Example</title>
<link rel="stylesheet" type="text/css" href="web.css" />
...
In the CSS Advanced Tutorial, we will see that there are other ways of linking external style sheets, but this will suffice for now.
To get the most from this guide, it would be a good idea to try out the code as we go along, so start a fresh new file with your text-editor and save the blank document as “web.css” in the same directory as your HTML file.
Now change your HTML file so that it starts something like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>My first web page</title>
<link rel="stylesheet" type="text/css" href="web.css" />
</head>
...
Save the HTML file. This now links to the CSS file, which is empty at the moment, so won’t change a thing. As you work your way through the CSS Beginner Tutorial, you will be able to add to and change the CSS file and see the results by simply refreshing the browser window that has the HTML file in it, as we did before.





Applying CSS | Source and Code System…
All I can say is keep it up. This blog is so necessary in a time when everyone just wants to talk about how many people someones cheated on their wife with. I mean, thanks for bringing intelligence back to the web, its been sorely missed. Great stuff. …
… [Trackback]…
Fantastic goods from you, man. Sun Damaged to “Sun Virgin”! I have understand your stuff previous to and you are just extremely magnificent. I actually like what you have acquired here, really like what you’re saying and the way in which you say it….
Buy Yankee Candles at Half Off…
[...]the time to read or visit the content or sites we have linked to below the[...]…
Awesome website…
[...]the time to read or visit the content or sites we have linked to below the[...]……
Buy Yankee Candles at Half Off…
[...]the time to read or visit the content or sites we have linked to below the[...]…
Visitor recommendations…
[...]one of our visitors recently recommended the following website[...]……
Websites we think you should visit…
[...]although websites we backlink to below are considerably not related to ours, we feel they are actually worth a go through, so have a look[...]……
affiliate marketing…
[...]here are some links to sites that we link to because we think they are worth visiting[...]…
Buy Yankee Candles at Half Off…
[...]the time to read or visit the content or sites we have linked to below the[...]…
Websites you should visit…
[...]below you’ll find the link to some sites that we think you should visit[...]……
adult social networking…
[...]here are some links to sites that we link to because we think they are worth visiting[...]…
TV Lamps…
The Truth behind Television Replacement Lamps….
Another Website Recommends Your Page…
[...]check below, are ѕоmе totally unrelated websites to ours, however, they're mоst trustworthy sources we use[...]…
Super Cheap Yankee Candles…
[...]we like to honor other sites on the web, even if they aren’t related to us, by linking to them. Below are some sites worth checking out[...]…
Great Clips Coupons…
[...]what follows are some links to web pages that we connect to as we believe they’re worthy of visiting[...]…
Websites we think you should visit…
[...]although websites we backlink to below are considerably not related to ours, we feel they are actually worth a go through, so have a look[...]……
Related……
[...]just beneath, are numerous totally not related sites to ours, however, they are surely worth going over[...]……
Found=> recommended your blog…
[...]The information mentioned while іn the article are the bеst avаіlablе [...]…
Websites you should visit…
[...]below you’ll find the link to some sites that we think you should visit[...]……
Read was interesting, stay in touch……
[...]please visit the sites we follow, including this one, as it represents our picks from the web[...]……
buy damansara house…
[...]you will find information that’s relevant to you if you want to buy damansara house[...]…
Websites worth visiting…
[...]here are some links to sites that we link to because we think they are worth visiting[...]……
Awesome website…
[...]the time to read or visit the content or sites we have linked to below the[...]……
Superb website…
[...]always a big fan of linking to bloggers that I love but don’t get a lot of link love from[...]……
Angry Birds Online…
[...]the following are a couple of references to websites which I connect to since we think they are worthy of visiting[...]…
Garmin 1490t Best Price…
[...]the time to read or visit the content or sites we have linked to below the[...]…
Sites we like……
[...]we like to honor many other websites on the internet, regardless of whether they aren’t associated with us, by linking to them. Under are a few webpages worth looking at[...]……
Found=> recommended your blog…
[...]The information mentioned inside article are ѕomе of thе beѕt аvaіlаblе [...]…
Recommeneded websites…
[...]Here are some of the sites we recommend for our visitors[...]……
shared webhosting…
[...]while the sites we link to below are completely unrelated to ours, we think they are worth a read, so have a look[...]…
basketball drills…
[...]here are some links to sites that we link to because we think they are worth visiting[...]…
Websites we think you should visit……
[...]although websites we backlink to below are considerably not associated with ours, we feel they are actually worth a go through, so have a look[...]……
Go no further…
Please don’t coerce me to review that blog item again have mercy….
Grandma Always Said…
It was my great grand mother who always told me that I should read more blogs like this….
Its hard to find good help…
I am regularly saying that its difficult to procure good help, but here is…
Ipad Stylus…
[...]below are a couple of listings to online websites I always connect to because we believe there’re worthy of browsing[...]…
travel…
[...]below you’ll find the link to some sites that we think you should visit[...]…
New wedding ? Great wedding Ideas ? Best wedding Ideas ?…
[...]below you’ll find the link to some sites that we think you should visit[...]…
Looking around…
I like to look around the internet, often I will just go to Stumble Upon and follow thru…
Dreary Day…
It was a dreary day here today, so I just took to piddeling around on the internet and found…
Need SEO advise ? Get some tips from us !…
[...]here are some links to sites that we link to because we think it will be helpful to you[...]…
Websites worth visiting…
[...]usually posts some very interesting stuff like this. If you’re new to this site[...]…
Websites you should visit…
[...]below you’ll find the link to some sites that we think you should visit[...]……
Related……
[...]just beneath, are numerous totally not related sites to ours, however, they are surely worth going over[...]……