Javatpoint Logo
Javatpoint Logo

How to add border in Html

In Html, we can add the border using the following two different ways:

  1. Using Inline Style attribute
  2. Using Internal CSS

Using Inline Style attribute

If we want to add the border in Html using the inline style attribute, then we have to follow the steps which are given below. Using these steps, any user can easily create the border.

Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the inline property for adding the border.

Step 2: Now, place the cursor inside the opening tag of that text around which we want to add the border. And then, we have to type the style attribute. And then, we have to type the border property in the style attribute same as shown in the following block:

Step 3: And then we have to give the border color in the border property.

Step 4: We can also give the style and width of the border which we want to add in the Html code. If we want to add then we have to type the border-width and border-style property just after the border property.

Step 5: And, at last, we have to save the Html file and then run the file in the browser.

Test it Now

The output of above Html code is shown in the following screenshot:

How to add border in Html

Using Internal CSS

If we want to add the border in Html using Internal CSS, then we have to follow the steps which are given below. Using these steps, any user can easily create the border.

Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the Internal CSS for adding the border.

Step 2: Now, we have to place the cursor in the head tag of the Html document and then define the styles inside the <style> tag, as shown in the following block. And then type the properties of border attribute into the id selector.

Step 3: And, at last, we have to save the file and then run the file in the browser.

Test it Now

The output of above Html code is shown in the following screenshot:

How to add border in Html





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA