I've been trying to get two styles for my H1 text with the following in my style sheet: h1.two { font-family: Tahoma; font-size: 12px; display: inline; } h1 { font-family: Tahoma; font-size: 14px; color: #33CC33; text-align: center; display: inline; } Yet when I try this: <h1 class="two">blah blah blah </h1> I still get the H1 style, can I do this? Ian
try switching it to this h1 { font-family: Tahoma; font-size: 14px; color: #33CC33; text-align: center; display: inline; } h1.two{ font-family: Tahoma; font-size: 12px; display: inline; } I personally always put my universal CSS on the top of the file, because CS will automatically class all H1 elements like that first, then you can specificy classes for exceptions to the rule.
No it still shows as H1 - What you are saying is put the style in the html file and that with over take the style in the sheet.
Have done this and it works fine....Thanks. <LINK href="../css2.css" type="text/css" rel="stylesheet"> <style type="text/css"> H1 {font-family: Tahoma; font-size: 12; text-align: left; display: inline; color: black;} </style>
Hey - I'm no css expert, so I did test this for you! If you just wanted to use the external style sheet, change your code to this: h1{ font-family: Tahoma; font-size: 14px; color: #33CC33; text-align: center; display: inline; } h1.two{ font-size: 12px !important; } 'two' will inherit all the properties from the main class, but the '!important' will mean the size is changed accordingly. ben
Or give them each a class <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <style type="text/css"> h1 { font-family: Tahoma; display: inline; } h1.one { font-size: 14px; color: #33CC33; text-align: center; } h1.two{ font-size: 12px; } </style> </head> <body> <h1 class="one">Testing</h1> <h1 class="two">Testing</h1> </body> </html> Code (markup):
It's not necessary to use the !important. The only thing changing is the font-size. Are you sure you're not getting the change? I can't not get different sizes. Look carefully for typos and syntax errors in and around the problem children. h1 { display: inline; font-size: 1.5em; } h1.two { font-size: 1em; } ======== <h1>hi there</h1> <h1 class="two">hi there</h1> Code (markup): cheers, gary
Thanks for all your tips...... As mentioned before I've got it to work so I'm happy with doing it that way. Ian