How to set div border in HTML | Example adding a border to a div

You have to use CSS and border property to set div border in HTML.

Explicit about all the border properties. Like width, type and color.

Shorthand

Note: Browsers don’t set the width or color to a default you’d expect.

Example of How to set div border in HTML

It’s an inline CSS example you can do it with Internal or External CSS, using id or class.

Output:

How to set div border in HTML

Another way you can use it:

How to add a border to a div

Use CSS border properties and specify the style, width, and color of an element’s border.

Do comment if you have any doubts and suggestions on this topic.

Note: The All HTML Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.