How to draw a dashed line css?

How to draw a dashed line using CSS?

+78
html css
Nov 17 '09 at 4:00
source share
14 answers

For example:

hr { border:none; border-top:1px dotted #f00; color:#fff; background-color:#fff; height:1px; width:50%; } 

See also <hr> Style with CSS .

+92
Nov 17 '09 at 4:18
source share
 <style> .dotted {border: 1px dotted #ff0000; border-style: none none dotted; color: #fff; background-color: #fff; } </style> <hr class='dotted' /> 
+16
Nov 17 '09 at 4:04
source share

Found the answer here with a google search for "css dotted lines":

 <div class="horizontal_dotted_line"></div> 

and in styles.css:

 .horizontal_dotted_line{ border-bottom: 1px dotted [color]; width: [put your width here]px; } 
+11
Nov 17 '09 at 4:03
source share

The accepted answer has a lot of toughness that is no longer required for modern browsers. I personally tested the following CSS in all browsers back in IE8, and it works great.

  hr { border: none; border-top: 1px dotted black; } 

border: none should be the first to remove all default styles that browsers apply to hr tags.

+9
Sep 11 '14 at 22:51
source share

Do you mean something like "border: 1px dotted black"?

link w3schools.com

+7
Nov 17 '09 at 4:01
source share

this line should work for you:

 <hr style="border-top: 2px dotted black"/> 
+7
Jun 02 '13 at 12:20
source share
 .myclass { border-bottom: thin red dotted; } 
+4
Nov 17 '09 at 4:01
source share

Add the following element to the element you want to have a dashed line.

 style="border-bottom: 1px dotted #ff0000;" 
+3
Nov 17 '09 at 7:28
source share

I tried all the solutions here and no one gave a clean 1px line. To do this, follow these steps:

 border: none; border-top: 1px dotted #000; 

As an alternative:

  border-top: 1px dotted #000; border-right: none; border-bottom: none; border-left: none; 
+3
Feb 07 '13 at 20:34
source share

use the following:

 <hr style="border-bottom:dotted" /> 
+3
Jun 02 '13 at 10:05 on
source share

To do this, you just need to add the border-top or border-bottom tag to the <hr/> as follows:

 <hr style="border-top: 2px dotted navy" /> 

with any type of line or color you want

+3
Jun 02 '13 at 15:35
source share

Using hr , two lines are created for me, one solid and one dashed.

I found this worked quite well:

 div { border-top: 1px dotted #cccccc; color: #ffffff; background-color: #ffffff; height: 1px; width: 95%; } 

Also, since you can make the width as a percentage, it will always have some space on both sides (even when resizing the window).

+2
Sep 29 '13 at 13:27
source share

Try the dotted line ...

 <hr style="border-top: 2px dashed black;color:transparent;"/> 
+1
Jul 19 '14 at 2:27
source share

The removed line after the item:

http://jsfiddle.net/korigan/ubtkc17e/

HTML

 <h2 class="dotted-line">Lorem ipsum</h2> 

CSS

 .dotted-line { white-space: nowrap; position: relative; overflow: hidden; } .dotted-line:after { content: ".........................................................................................................."; letter-spacing: 6px; font-size: 30px; color: #9cbfdb; display: inline-block; vertical-align: 3px; padding-left: 10px; } 
0
Dec 11 '15 at 11:33
source share



All Articles