Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I apply a border-bottom to each line of a DIV?

Tags:

html

css

My code:

div {
    border-bottom: 1px solid;
} 
<div>
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua.
</div>    

As the text is long enough word-wrap is taking place. Is it possible to apply a CSS formatted bottom border to the each line of text? Moreover, is it possible to have every bottom border to be at full width of DIV (even if text is only half or less of line width)?

like image 233
vxl Avatar asked Jan 23 '12 19:01

vxl


4 Answers

text-decoration:underline will work, but if you want more control over the "underline" (colors, styles, width) you can do this:

div {
    border-bottom: 1px solid;
    display:inline;
} 

Demo: http://jsfiddle.net/ckt8L/

like image 55
Wesley Murch Avatar answered Nov 05 '22 21:11

Wesley Murch


well for one, wrap the text in <p>

then you can apply

p {border-bottom: 1px solid black;}

like image 21
David Nguyen Avatar answered Nov 05 '22 19:11

David Nguyen


You could just apply an underline to the text:

div {
    text-decoration: underline;
}
like image 1
animuson Avatar answered Nov 05 '22 21:11

animuson


A div is a block element, instead of that, use a span that is an inline.

<style>
div span{
    border-bottom: 1px solid;
} 
</style>
<div>
   <span>
      Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
      tempor incididunt ut labore et dolore magna aliqua.
   </span>
</div>  

See this fiddle with a different approach, using a background as border bottom:

http://jsfiddle.net/YcSUQ/3/

like image 1
Ricardo Castañeda Avatar answered Nov 05 '22 20:11

Ricardo Castañeda