...

View Full Version : Using a Style Sheet



Tombo
12-04-2002, 06:33 PM
Quick question...

I dunno if it's called a "stylesheet" or not, but that's just what I'm assuming... to my understanding, I can have a text file (*.txt) with all my style settings, then have every html page that wants to use those settings just refer to that text file - instead of having the same style tag on every page header. (This way I could modify the style settings and it would change on every page, instead of having to change every page individually.)

Yes... I think that's what a "style sheet" is.

Anyways, the quick question: What's the tag needed in the <head> section to tell an html document to refer to this text file for it's style settings? And is there anything special I should put in the text file, or just the style settings?

(I searched for the answer prior to posting with little help - mainly because I didn't know how to summarise my question into a few search terms, and when I tried I got little to no help. :p)

Thanks in advancefor answering my newb question. :rolleyes:

cg9com
12-04-2002, 06:46 PM
not a .txt file, a .css file "Cascading Style Sheet"
call it inside of the header like this:
<link rel="stylesheet" type="text/css" href="name.css" />

an example of what goes inside of your external file would be.

body {
background-color:#ffffff;
}

this will make your background clor of the document white.
notice it sys "body" this represents the <body> tag on your page, the background-color specifies just that.

also you can define your own names like this

.header {
color:#000000;
}

now anytime you add class="header" inside of a tag, the text will be black
EX: <div class="header">this text is black</div>

the color attribute represents color of text.
hope thats clear enough, if you need any help you can contact me or ask in the forum
good luck

more info can be found at
http://www.w3schools.com/css/default.asp

meerkat
12-04-2002, 06:51 PM
Tombo…

A stylesheet is INDEED a text file but the correct suffix is .css and not .txt.

CSS stands for Cascading Style Sheets and is good way of setting up styles to be used across a website. Or as you said "This way I could modify the style settings and it would change on every page, instead of having to change every page individually"

The code for adding to the 'head' section is

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

Where yourstyle is the text file you create for your website.

meerkat

jkd
12-04-2002, 09:15 PM
Originally posted by meerkat
A stylesheet is INDEED a text file but the correct suffix is .css and not .txt.

You could use .abcd if you wanted, as long as the server knows to serve it with the mime-type "text/css". Contrary to popular belief, file extensions really mean nothing on the web.

cg9com
12-04-2002, 10:22 PM
intresting point jkd

ronaldb66
12-05-2002, 10:51 AM
file extensions really mean nothing on the web
But they do to us humans... While jkd probably is totally right (i wouldn't know), i personally find it preferable to give my external style sheets the extension .css, so i still know it's a style sheet lateron.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum