Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why doesn't this work? (I'm going mad)

Status
Not open for further replies.

KingofSnake

Programmer
Jul 25, 2000
73
US
I want something like this:

<b>Title:</b> TextTextText

I wanted to do it using css. I have the following definitions:

p {font-family : arial; font-size : 8pt; font-weight : normal}
h1 {font-family: arial; font-size : 8pt; font-weight : bold}

However, when I do this:

<p>
<h1>Title:</h1> TextTextText
</p>

It doesn't work at all. The title ends up looking like a standard h1 header, and the &quot;TextTextText&quot; looks just like how I want the h1 to look. What's going on? I don't understand it at all.
KingOfSnake - The only sports drink with ice crystals
(and marshmellos!)
 
try...

p {font-family : arial; font-size : 8pt; font-weight : normal}
p.h1 {font-family: arial; font-size : 8pt; font-weight : bold}

This should sort it out


Klae

You're only as good as your last answer!
 
sorry that won't work instead of doing p.h1 do p h1 Klae

You're only as good as your last answer!
 
Although Klae is right and that will solve your problem you may find that the text doesnt format as you wish. Be carefull when assigning styles to p and h tags as these have a line break in as default after the closing tag hence in your example above there would be a line break after the text within the h1 tag.

This can be avoided by using classes. To define a class use

.bold{font-weight:bold}

now your code can be...

Code:
<p><span class=&quot;bold&quot;>Title</span>textextext</p>

Even if you want the linebreaks,it is better practice to use classes. It will help avoid many obstacles in using CSS.

Alternatively you could have the h1 tag outsideof the p tag......(in theory they are not supposed to nest like that anyway).

Hope this helps

Starfishh :) you said NetWhat?
 
Thank you both very much.
KingOfSnake - The only sports drink with ice crystals
(and marshmellos!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top