• Post category:HTML

 How to Create HTML Border Around Text Only

 HTML Border Around Text Only

This tutorial will show you the solution for HTML border around text only. To create a border around your text only, you can use the CSS border property which will create a border around your text by default.

Step by step for HTML border

We can give three values in the border property namely border size, border type, and border color.

<title>HTML border</title>
<script src="./jquery-3.6.1.js" type="text/javascript"></script>
<style type="text/css">
border: 2px solid red;

<h1>Heading Text1</h1>



html border around text only

1. Here, we have written the HTML basic syntax.
2. In the body, we have a <h1> tag with some text inside.
3. In the CSS Style tag, we first select h1 using the element selector then apply the border using CSS border property and assign the value 2px of thickness, solid border type, and border color red.
4. See the above output, the border is created around the text.


So, I hope guys, this article on HTML border helps you.

Leave a Reply