Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multi line dotted or dashed text-underline

Tags:

css

Because CSS text underline only allows a solid line and its position is right at the bottom of strings, I'm using border-bottom plus a little padding to achieve dotted or dashed text underline.

h2{border-bottom:1px dotted #999; padding-bottom:5px;} 

now, the problem is, when the heading (or paragraph, or whatever element) text takes 2 lines or more, the dotted underline simply does what every border does, which is stay on the bottom of the block element. If I use text-underline style, the underline stays with the text, but text-underline only supports a solid line, and as far as I know, no padding.

So how do I display multi line texts with dotted or dashed underline ?

Thanks

like image 681
Henson Avatar asked Dec 06 '10 10:12

Henson


People also ask

How do you make a dotted underline in CSS?

Adding a dotted or double underline The text-decoration property does not have a “double” or “dotted” value. Instead, you can use the border-bottom property to add double or dotted underlining. You can remove a link's default underline by setting the text-decoration proeprty to “none.”

How do you underline text in CSS?

The property text-decoration-line is used to underline the text. This property has three values that are overline, underline, or line-through. So, the value underline is used to underline the text in CSS. This value draws the underline beneath the inline text.


1 Answers

h2 {   border-bottom: 1px dashed #999;   display: inline; } 

So you receive what you need.
But you have to keep in mind that <h2> is then (of course) no longer a block element. But you can "avoid" that by putting a <h2> in a <div>.

like image 199
thedom Avatar answered Sep 21 '22 00:09

thedom