What am I doing wrong?

Soldato
Joined
6 Jan 2006
Posts
3,423
Location
Newcastle upon Tyne
Trying to make a start with style sheets but I'm stuck at the first hurdle!

Style sheet:

Code:
p 	{
	font-family:Tahoma;
	color:#FFFF00	
	}

p2 	{
	font-family:"Times New Roman";
	color:#CCCCCC
	}

Html:

Code:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
<link rel="stylesheet" type="text/css"  href="test.css" />  


<title>CSS test</title>
</head>

<body>

<p>Test this should be tahoma</p>

<p2>This text should be different!</p2>

</body>
</html>

But the second lot of text is staying black? http://www.mmassociates.co.uk/test/

What have I done wrong?

Thanks
 
Exactly. It's the same for any HTML element.

Alternatively, define the elements more precisely:

For example:

Code:
p {style stuff}

div p {other style stuff}

applied to

Code:
<body>
<div>
<p>...</p>
</div>

<p>...</p>
</body>

Would apply different styles to each paragraph tag as you have specified that the <p> in the <div> has a different style to every other <p>.

A combination of this "element nesting" and the application of classes is how CSS works (and breaks).
 
Have a look at a load of tutorials online. www.w3schools.com has loads of good ones. This stuff should only take a few weeks to sink in. Just keep plugging away and coding and it will become second nature.
 
Back
Top Bottom