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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Border length of text 1

Status
Not open for further replies.

dmacster

Technical User
Jan 28, 2005
670
US
Is there a way to make a top and bottom border that is only as wide as the line of text? I've been trying and can't seem to get the border above and below (no side borders) to only extend however wide the text is.

I also tried using overline and underline, which worked for length, but butted right onto to the text. Or does anyone know of how to make the overline and underline properties offset - sort of like a baseline shift in programs like Quark?

Thanks,
Donna
 
This example should do it across browsers for you:

Code:
.myHead {
  width:auto;
  font-size:1.1em;
  line-height:1.6em;
  border-top:1px solid black;
  border-bottom:1px solid black;
  padding: 0.5em;
}
...
<h3 class="myHead">Some text goes in here</h3>

Hope that makes some sense!
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
I'll try it, Jeff. Thanks. I'll let you know how it works.

Donna
 
Jeff -

I tried that, but could not get it to display - copied your css exactly - but for the name (mine's a paragraph class)

CSS
Code:
.address {
  width: auto;
  font-size: 1.1em;
  line-height: 1.6em;
  border-top: 1px solid black;
  border-bottom: 1px solid black;
  padding: 0.5em;
}

and HTML
Code:
<body>
<p class="address">here's some stuff that would have border above and below hoping</p>
<p class="address">only to have this run the length of the text</p>
</body>

Ideas?

Thanks,
Donna
 
It looks like it's a non-starter. You will have to set the widths of each block-level item manually (use ems so they scale). The borders work... just not the widths... sorry :(

Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Thanks anyway Jeff - I appreciate your timely answers.

I'll see how I can work it.


Donna
 
If you want borders only around text, you should add that to an inline element, such as span:
Code:
<p><span style="border-top: 1px solid black; border-bottom: 1px solid black;">here's some stuff that would have border above and below hoping</span></p>
 
Most excellent, Vrag! A star to you - it works.

Thanks,
Donna
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top