Jump to content

Linking Style Sheet?


ReptiGuy

Recommended Posts

For some reason I have a lot of problems linking to a style sheets on my HTML pages.This is what I did:

<!--Creator: ~~~~~~~Page Name: IndexDate Created: 1/09/2009Updated: ???--><!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>	<title>	Golden Valley Reptiles-Homepage	</title>	<link rel="stylesheet" type="text/css" href="goldenvalleyreptiles.css"/></head><body><p class="p">Blah</p></body></html>

This is what I have on the CSS:

body(background-color: #FFBE30;}.p{font-size: 2em;color: red;}

I know the link to the css page is correct.More info:I have the CSS file and the HTML file in the same folder.

Link to comment
Share on other sites

try this:<link rel="stylesheet" type="text/css" href="./goldenvalleyreptiles.css"/>And you don't say what trouble your code is giving you. Is the CSS file not working?On a side note, why is there a period in front of the 'p' in the css file? That creates a class = p which may be an issue since 'p' is also an element name...

Link to comment
Share on other sites

try this:<link rel="stylesheet" type="text/css" href="./goldenvalleyreptiles.css"/>
That didn't work.
And you don't say what trouble your code is giving you. Is the CSS file not working?
For some reason when I view the html page on the internet the CSS isn't working so it's just a white page with black text.
On a side note, why is there a period in front of the 'p' in the css file? That creates a class = p which may be an issue since 'p' is also an element name...
Aren't you suppose to put a period in front of class names in a CSS file?
Link to comment
Share on other sites

Aren't you suppose to put a period in front of class names in a CSS file?
Yes you are. But are you calling the class "p", or are you trying to style everything within "<p>...</p>"? If it's the former and not the latter it's okay. But if it's the latter, you need to lose the period. To style all text within every <p></p> tag you would write your CSS as:
p{  font-size: 2em;  color: red;}

But if you want to create a class to use within various elements, you would write your CSS as:

.p{  font-size: 2em;  color: red;}

It's just that creating as class "p" could get confusing when writing or coming back and modifying your HTML. I hope I haven't muddied things up too much. :)

Link to comment
Share on other sites

Yes you are. But are you calling the class "p", or are you trying to style everything within "<p>...</p>"? If it's the former and not the latter it's okay. But if it's the latter, you need to lose the period. To style all text within every <p></p> tag you would write your CSS as:
p{  font-size: 2em;  color: red;}

But if you want to create a class to use within various elements, you would write your CSS as:

.p{  font-size: 2em;  color: red;}

It's just that creating as class "p" could get confusing when writing or coming back and modifying your HTML. I hope I haven't muddied things up too much. :)

The only reason I gave it the class name "p" is because I just wanted to see if the CSS was working but I just had something wrong with the background-color: tag.I guess you guys are right though and I could have just used p{ instead of .p{. I just wanted to do something quick to find out if the css was working and I didn't thinking about using p{.I still can't get the css to work on my html page.
Link to comment
Share on other sites

If you have Firefox and the Web Developers Extension, load the page then check to see what CSS is present for the page.Also, check, re-check, and then check again the spelling of the file name of the CSS file being used. They are in the same folder, correct?

Link to comment
Share on other sites

I didn't see the fix while viewing on my Laptop until I took the file into my text editor which includes a bracket-matching function. While hovering around, I recognized that there was a mis-match of the Braces.Rookie mistake, but we all still make them. Glad to help.

Link to comment
Share on other sites

I just glanced at this thread for the first time. That paren was the first thing I noticed. Then I found myself reading faster and faster to see when you guys would catch it. Really, my heart was racing.Anyway, good call, and NOT a noobie mistake at all. The little stuff gets me all the time.

Link to comment
Share on other sites

That didn't work.For some reason when I view the html page on the internet the CSS isn't working so it's just a white page with black text.Aren't you suppose to put a period in front of class names in a CSS file?
The issue isn't the period, it's using a class that is also a selector.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...