View Full Version : linking with css


cutout
03-26-2006, 05:32 PM
this is my first time trying to use css, and i've immediately come up against problems! I'm trying to make a layout with it.

First: using the exact link-to-external-style-sheets code given on this site... nothing happens! when i open up a page containing the link, it just looks blank and white, even though the coding on the sheet is ok (because when i put the coding internally on a page, it works). What's going on?

Second: I dont really understand linking with css layouts. Say I want the centre div to be the content, and I insert content on it on the .css file... if someone follows a link, I want the centre div to contain different content. Does that make sense? Basically, I don't understand how to change the content of a page using external style sheets. I don't want to have to copy and paste the code into every page, though it looks like thats the only way to solve these problems.

Any help much appreciated, I'm sure I'm just being completely dumb.

maztrin
03-26-2006, 07:46 PM
1: how are you linking to your stylesheet?
if you css is the same directory you can link to it like this:
<link href="main.css" rel="stylesheet" type="text/css" />
if it is in another directory you can link to it like this:
<link href="directory/sylesheet.css" rel="stylesheet" type="text/css" />
if these dont work for some reason try different ways of linking to it and make sure your CSS doesn have any errors in it, that are making the css not display.

2.you cannot change the content of your site using CSS, CSS is just for styling your pages.
what you do with CSS is create a class or id in your CSS file:
eg.
.content{
font-family:Arial, Verdana;
color:red;
background-image:images/background.jpg;
font-size:1em;
etc
}
then on your html page you do this:

<html>
<head>
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<p class="content">this is all the main content. You can style this with css however you want. </p>

</body>
</html>

this will dsiplay the conent like this:
this is all the main content. You can style this with css however you want.

afirefly
03-26-2006, 09:58 PM
since ur having trouble linking you could make like practice
linking to test ur skill at linking

names need to be the same I have changed the name of a file
and the link does NOT work.


at first i think is easyiest to have in same directory.... for me anyway.

cutout
03-27-2006, 06:34 AM
yeah its in the same directory, and that's the link i'm using... god knows why it isnt working!

I think i understand the content thing now though, thanks a lot.