9 Border to DIV Element in HTML Examples


Post Banner

In this Tutorial, we will see ways in which we can add borders to div elements in HTML Style attributes border and border-style,

Example 1: Solid Border

Some text

Code:
<div style="border:1px solid">Some text</div>

Example 2: Solid Border with color

Some text

Code:
<div style="border:1px solid #00ff22">Some text</div>

Example 3: Dotted Border with color

Some text

Code:
<div style="border:1px dotted red">Some text</div>

Example 4: Dashed Border with color

Some text

Code:
<div style="border:1px dashed red">Some text</div>

Example 5: Double Border

Some text

Code:
<div style="border-style:double">Some text</div>

Example 6: Groove Border

Some text

Code:
<div style="border-style: groove">Some text</div>

Example 7: Ridge Border

Some text

Code:
<div style="border-style: ridge">Some text</div>

Example 8: Inset Border

Some text

Code:
<div style="border-style: inset">Some text</div>

Example 9: Outset Border

Some text

Code:
<div style="border-style: outset">Some text</div>

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap