View Full Version : Referencing CSS in HTML

Dec 22nd, 2008, 11:06 PM
I'm extremely new at CSS, and I just did a test-run CSS page/file. Now I have no idea how to reference the individual "elements" within it on an HTML page. Would I use <link rel> and just list each one separately in the header? Or do I need to call up each one in the page where I want to use it. Thanks in advance.

Dec 22nd, 2008, 11:22 PM
Do you have the css linked to the page? If so, then the reference to the elements is automatic - you don't have to do anything.

Dec 22nd, 2008, 11:28 PM
I think so...I'll have to check on that. Additionally, in my .css code, I have done 3 different text styles...text1, text2, and text3. How do I use those in the HTML, or do I have to rename them?

Dec 22nd, 2008, 11:31 PM
it would be better posting your code so we can see what you have done so far.

However, you may wish to look at: http://www.w3schools.com/css/css_examples.asp for various examples on how to call css with html. basically if you want to use a style for different links provided you have created the css for each link, you would do something like:

<a href="http://www.yousite.com" class="text1">text</a>

that will display the output of "text" in the style that you set the class "text1" to in your css.

Also be sure that in your css file it is a class for example:

.text1 {

is a class whereas:

#text1 {

is an id.

Dec 23rd, 2008, 02:27 AM
If you're starting out, I'd suggest that you have a read around the subject to minimise the amount of time you spend repeating all the mistakes the rest of us made early on. A really good place to start is Build Your Own Web Site The Right Way Using HTML & CSS (http://www.sitepoint.com/books/html1/).

You'll find that there's much more to CSS than text styling - it's a completely different approach to page design from table-based layouts, which takes some learning, but your reward is well-ordered semantically coded content and a very powerful way to control your page presentation.

Dec 23rd, 2008, 03:53 PM
Thank you much guys...that's what I was looking for.