| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Registered User
Join Date: Dec 2004
Posts: 42
|
Border underline for heading text...
Hey there. I'm having a problem creating the desired effect for some heading text. As per a design I'm coding from, I need the underline of the heading text to be a bottom margin (due to it's positioning and it's thickness). I've added the underline effect with the border-bottom property, but my question is... how do I get the "underline" to only run along as far as the text itself goes, while behaving like a block level element in relation to the surrounding text? If I make the heading into a inline element, the border-bottom underline displays how I would like, but unfortunately it effs up in terms of layout. Is there any way to achieve this without resorting to putting the heading inside a div? Any help would be muchly appreciated. |
|
|
|
|
|
#2 (permalink) |
|
389 ppm and rising
Join Date: Aug 2005
Location: Järvenpää, Finland
Posts: 4,940
|
Sounds like that's something you need to incorporate into the text itself, rather than try to get CSS to do it. You might even need to turn the affected text into a graphic, which probably won't be a big problem for heading text. My free fonts www.utfi.net
|
|
|
|
#3 (permalink) |
|
Registered User
Join Date: Dec 2004
Posts: 42
|
Unfortunately it looks as if it does actually need to be text and not graphic. Hopefully there's a way, but if it can't be done I'll have to take it up with the designer on Monday. In the past I've actually thought about including such headings into one my own designs, only to decided against it as I was unsure of how to implement them correctly. I'd be very interested to know of a method, if only for that reason! |
|
|
|
#6 (permalink) | ||
|
Registered User
Join Date: Dec 2004
Posts: 42
|
Quote:
display:block was precisely what I wasn't using in the header, due to that fact that it forced the border/underline beyond the length of the text. Instead, I made the header inline, which caused said layout problems. Quote:
I have little experience in using <span>. For some reason I was thinking that the only way around this might be to use a <div>, but was reluctant to put that among text. Please excuse the stupidity, I'm only a part time coder (more of a designer), and doing this task as part of work experience! I'm learning all the time! A question - is <span> preferable to <em> or <strong> in such scenarios? |
||
|
|
|
#7 (permalink) |
|
dt immigrant
|
erm, I think span is "inert" from a presentational point of view. Which means it bears little importance on the way tex is rendered in the browser or on the way it is interpreted by screenreaders or search engines, whereas <strong> and <em> imply emphasis, rendering text bold or italic. Or I might be completely wrong. Some reading here SPAN and Div Also read on block and inline elements |
|
|
|
#8 (permalink) | |
|
Dr. Lucien Sanchez
Join Date: Mar 2003
Location: UK
Posts: 5,527
|
Quote:
Anyway, span away. |
|
|
|
|
#9 (permalink) | |
|
Registered User
Join Date: Dec 2004
Posts: 42
|
Quote:
Also, is it better to have such tags within the <h#> tags or enclosing them? |
|
|
|
|
#11 (permalink) | |
|
Registered User
Join Date: Dec 2004
Posts: 42
|
Quote:
I've just tried: Code:
But for some reason adding clear:right doesn't work (the paragraph text runs up alongside it's right side)... although adding clear:left to <p> has the desired effect. It appears to work wonderfully in fact, and would eliminate the need for me to use <span> in this instance. But just to make sure, is adding clear:left to a paragraph okay? Could it cause problems? |
|
|
|
|
#16 (permalink) |
|
Senior Member
Join Date: Jan 2005
Posts: 12,340
|
So, if I get you right, you want to underline text in a heading? If so, why are you using border-bottom?? What's wrong with h* { text-decoration: underline; } I really hope I'm missing something... Code:
However, that above is invalid CSS since you are required to specify a width on a float (except in the case of replaced elements, which headings are not). So, it looks like floating it to control the width is out. |
|
|
|
#18 (permalink) |
|
Senior Member
Join Date: Jan 2005
Posts: 12,340
|
Ah, I get it. So, what's wrong with: HTML Code:
Code:
Span will be a better bet for you since the heading itself already implies emphasis and you're only using the inline element as a style hook (i.e. it should have no semantic meaning). |
|
|
|
#19 (permalink) | |
|
Registered User
Join Date: Dec 2004
Posts: 42
|
Quote:
But I'm unsure if it's a right way of doing things, so I'm using <span> for the time being. |
|
|
|
|
#20 (permalink) | |
|
Senior Member
Join Date: Jan 2005
Posts: 12,340
|
Quote:
Besides, like I said, the display: inline; float: left; combination is redundant. |
|
|
![]() |