Help with my webpage code... please

<!DOCTYPE html PUBLIC “-//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”>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8” />
<title>www.milesornish.com</title>
<style type=“text/css” media=“all”> </style>
</head>

<body>
ol {
background-image: url(gradientbackground.png);
background-repeat: repeat-x;}

</body>
</html>


This is what my code looks like right now. I am trying to make it so that image shows up as the background of the page, and make it be part of the css so it is on the other pages too.

Can someone please help me figure out what I did wrong?

Thanks,
Miles.

I’m not really sure what you’re going for with the ‘ol’ class.

Do this:

<!DOCTYPE html PUBLIC "-//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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>www.milesornish.com</title>
<link rel="stylesheet" type="text/css"
href="NAME_OF_EXTERNAL_STYLESHEET.css" />
</head>

<body>

</body>
</html>

Then have an external .CSS document in the same root folder as your .HTML page with this code:

body 
{
background-image: url("gradientbackground.png");
background-repeat: repeat-x;
}

That should work.

Oh and if you want it to apply to all pages, be sure to put the <link> code in all the headers of your pages.

where do I put the second part again?

I am confused.

The second part should be in a seperate .css file. All CSS should be there.

Read this website: http://www.w3schools.com/css/default.asp it will really help.

Oh, and I’d use a strict doctype, not a transitional one. Otherwise you’ll get bugs in IE.

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>

Simplest way would be to just make it a separate file. Copy/paste the second chunk of code into a new notepad document, save it as a .CSS file. You’re basically referencing an external file in your .HTML page. This method is much more convenient than in-line CSS code, because you can just change the .CSS file, and any .HTML document that references that file will change too.

Okay, I have it saved as milesornishbackground.css on my desktop (i wrote it in msword).

where do I put the link to it in my code? Like between which tags?

Like I had in my first post:

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

Put that in the header.

Make sure the .html and the .css files are in the same folder.

<!DOCTYPE html PUBLIC "-//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">
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>www.milesornish.com</title>
<link rel="stylesheet" type="text/css"
href="milesornishbackground.css" />
</head>

<body>

</body>
</html> 

I still am not seeing a background image, but oh well.

I am tired and feeling stupid, night everyone.

-Miles

My guess is your two files aren’t in the same folder…you also need the image file in the same folder, the way you have it.

I wouldn’t use a .PNG for that anyway. And I wouldn’t use Word, just use NotePad.

I’m on a mac, so I have TextEdit. It wouldn’t let me save it is a .CSS

I put the files right next to my index.html

You can’t simply put style code inside your body and expect it to work.

You also do not need an external style sheet to accomplish anything. After changing a few things it seems like you just need to do this (I didn’t check everything but I added quotes and changed your logic). I have not tested it out though.

I would suggest reading some basic guides on HTML and CSS before you try to do anything like this again. Keep in mind that your style tags need to be within the head, and if you do not know how an html page is segmented you will not really get anywhere.

<!DOCTYPE html PUBLIC "-//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">
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>www.milesornish.com</title>
<style type="text/css"> 
body { background-image: url('gradientbackground.png'); background-repeat: repeat-x;}
</style>
</head>

<body>
Hello World!
</body>
</html>

Thank you, it worked.

so now I can use part of that for each of the pages, and just change one so that it changes all of it?

No.

With the way that I did it there, if you want to change the background on all of your pages you will need to go into each file and change the style.

If you only wanted to change it in one place you would need to have an external stylesheet.

a file, named style.css should contain:

body { background-image: url('gradientbackground.png'); background-repeat: repeat-x;}

and your html file should be:

<!DOCTYPE html PUBLIC "-//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">
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>www.milesornish.com</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
Hello World!
</body>
</html>

Make sure style.css is in the same directory as your html files and it will work.

Okay thank you!

edit: I’m not sure if I am doing the style sheet correctly, but class is starting. Thanks for the help!

If that worked, what was I telling him wrong?

I don’t think you told him anything wrong, but he might not have changed “NAME OF EXTERNAL STYLE SHEET” to the stylesheet he created.

Plus, we only know that the html page worked that i posted original with the style internalized in the file. He may not have got the external version working.

I haven’t gotten the cascading style sheet to work yet. Still trying to figure it out…

where do I put the style.css?

Like, I have it in my milesornish_site folder, next to my index, but I am confused how to actually implement it.

Mornish, all you need to do is have the <link> tag in the header of your .html document to reference the style sheet.

ohhhh okay.
Thanks so much.

Hey everyone, I’ve got another question about the external style sheets.

I am now writing up the website from code, and so, is the external style sheet also html?

edit: Let me clarify a bit, would I just put the background image and that sort of stuff in the external style sheet, and then link to it?