Skip to content Skip to sidebar Skip to footer

How To Draw A Dotted Line With Css?

How can I draw a dotted line with CSS?

Solution 1:

For example:

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

See also Styling <hr> with CSS.


Solution 2:

The accepted answer has a lot of cruft that is no longer required for modern browsers. I have personally tested the following CSS on all browsers as far back as IE8, and it works perfectly.

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

border: none must come first, to remove all the default border styling that browsers apply to hr tags.


Solution 3:

<style>
    .dotted {border: 1px dotted #ff0000; border-style: none none dotted; color: #fff; background-color: #fff; }
</style>
<hr class='dotted' />

Solution 4:

Using HTML:

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

and in styles.css:

.horizontal_dotted_line{
  border-bottom: 1px dotted [color];
  width: [put your width here]px;
} 

Solution 5:

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

w3schools.com reference


Post a Comment for "How To Draw A Dotted Line With Css?"