/    Sign up×
Community /Pin to ProfileBookmark

Controling line height of a single line

Greetings,

I have a class called “header” and I am trying to give it a touch of extra space between it and the next line.

All of my headers are just a few words and thus on one line. I tried placing “line-height: 1.5em” in my “header” class and it shows up correctly in Dreamweaver but not in IE. My thought is, because it is only a single line, that class value does not kick in because there is no second line for that class.

Is there a way to conrol this in CSS or am I going to have to resort to using a….gulp…..spacer?

Thanks in advance..

to post a comment
CSS

11 Comments(s)

Copy linkTweet thisAlerts:
@MstrBobNov 12.2004 — Why not give it a bottom margin? margin-bottom:1.5em;
Copy linkTweet thisAlerts:
@niemieauthorNov 12.2004 — Hmmmm, that doesn't work. Here is the class:

.header {


font-family: Verdana, Arial, Helvetica, sans-serif;

color: #333333;

font-weight: bold;

text-decoration: underline;

font-size: 13px;

margin-bottom:2em

}

The header is just one line of text, with another line of text (non-header class) directly under it. I even tried to go up to 50em but still no result....
Copy linkTweet thisAlerts:
@NogDogNov 12.2004 — To what HTML element type are you applying this class?
Copy linkTweet thisAlerts:
@niemieauthorNov 12.2004 — the <font> element.

<td width="70%" class="body">

<font class="header">HEADER GOES HERE</font><br>

Body text starts here.....

</td>
Copy linkTweet thisAlerts:
@NogDogNov 12.2004 — [i]Originally posted by niemie [/i]

[B]the <font> element.



<td width="70%" class="body">

<font class="header">HEADER GOES HERE</font><br>

Body text starts here.....

</td> [/B]
[/QUOTE]

Aha, since font is an inline element by default, I think you need to add [FONT=courier new][B][COLOR=darkred]display: block;[/COLOR][/B][/FONT] to your header class, perhaps, for things like margin to work?

[i]PS: <span> would probably be more appropriate that <font> here.[/i]

[b]PPS: In fact, wouldn't it make more sense to make this a h1, h2, h3, or h4 tag?[/b]
Copy linkTweet thisAlerts:
@niemieauthorNov 12.2004 — Sorry, obviously I am a newbie.

So if I do header tags, I still have to control the spacing with a margin or something in CSS, right?
Copy linkTweet thisAlerts:
@NogDogNov 12.2004 — Sure, you could do something like this:
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang='en'&gt;
&lt;head&gt;
&lt;META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'&gt;
&lt;title&gt;Untitled&lt;/title&gt;
&lt;style type="text/css"&gt;
table {
border-collapse: collapse;
border: 2px solid black;
}
td {
margin: 0;
padding: 1em;
}
.header {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #333333;
font-weight: bold;
text-decoration: underline;
font-size: 13px;
margin-bottom:2em
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;h1 class=header&gt;Header Text&lt;/h1&gt;
&lt;p&gt;This is the body text of the table cell&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;

However, I suspect the "semantically correct HTML" police may start suspecting you of using tables for formatting purposes instead of simply the presentation of tabular material. ? (Hard to tell yet without seeing what you're really trying to do.)
Copy linkTweet thisAlerts:
@MstrBobNov 12.2004 — Yes, you should be using header tags, since it is a header. And since, by default, headers are block level elements, all you need to do is then add a bottom margin.

May I ask why you are using the depreceated <font> tag, and incorrectly using tables when you obviously seem to know CSS? They are so inefficient. Headers shouldn't be in body cells. Period. If it's tabular data, you should be using table headers, <th> for the top row. Otherwise it's incorrect usage of tables. ?
Copy linkTweet thisAlerts:
@niemieauthorNov 12.2004 — ....because I don't really know CSS - I get the general idea from what I have taught myself but I have nowhere near the knowledge of it to control layout - at least not yet.

Thanks for the help guys! Much appreciated.
Copy linkTweet thisAlerts:
@niemieauthorNov 12.2004 — I see now that is was just my use of the font element vs what it should have been, the header element.

Let me ask this - is there a way to have an image in every "header" class? In this case it's just a little bullet type image that I want at the end of the header with a space between the words and header? How do you do this with CSS?
Copy linkTweet thisAlerts:
@MstrBobNov 12.2004 — Set the image as a background. If you want it on the left, you'd do something like:

.header {

background: url('bullet.gif') top left no-repeat;

padding-left:30px;

}

You'd put padding on the left so that it pushes over the text, and so looks like there's an image next to it.
×

Success!

Help @niemie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...