-

2011年8月3日星期三

What's wrong with this HTML / CSS?

-I'm new to CSS and am trying to figure out why its not formating my simple page as I want. First i've tried linking to an outside document (in the same folder!!) see below, which is now commented out. Then I tried just adding simple CSS into the HTML doc and its not working either. Yes, the document is saved as an HTML and the other is a .CSS, they're in the correct folder, etc. Am i doing this correct and maybe its a browser issue?





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-鈥?br>
<html xmlns="http://www.w3.org/1999/xhtml">



<head>

<title>Kyle's site</ title>

<!--<link rel="stylesheet" type="text/css" href="MainStyleSheet.css" />-->

body {font-family:helvetica, arial, verdana, sans-serif;}

h1{georgia, times, serif;}

p{font-size:12;}

</head>



<h1>Kyle's Site</ h1>

<h3>A site designed by Kyle BB</ h3>



<body>

<p>

Currently under construction. Please check back soon!

</p>

</body>

</html>



I tried the commented-out section first, which did not seem to work at all. After that I commented out that link and then added the css directly into it but that just displayed it right on the page as if it weren't code. Help! thanks!You shouldn't have the <! in front or back.

Just keep it like this:

<link href="MainStyleSheet.css" rel="stylesheet" type="text/css" media="screen">

That should work for you, that links to an external style sheet.

And remove the internal CSS, put it in the external CSS sheet...and make sure you keep the css document in the root folder, I suppose you are though.
I don't necessarily see anything wrong with your <link> tag, but I always put the <link> tag before the <title> tag in the header and it works fine, you might try that.



I also noticed in your terminating </title> tag, you had a space between the / and the word "title". Not sure that that would affect anything though.



To get the inline CSS to work in your header, you need to put it in a <style> tag, e.g.:



<head>

<style type="text/css">

body {font-family:helvetica, arial, verdana, sans-serif;}

h1{georgia, times, serif;}

p{font-size:12;}

</style>

<title>Kyle's site</title>

</head>

没有评论:

发表评论