How to Create a Border Around Text in HTML
- 1). Launch your computer's text editor and begin a new document.
- 2). Type in the HTML code that creates a Web page:
<html>
<head>
<title>Enter a name for your Web page here</title>
</head>
<body>
</body>
</html> - 3). Enter the text of your Web page between the "<body></body>" tags.
- 4). Type in "<div></div>" tags before and after your content. Additionally, enter "style=" in the opening "<div>" tag to prepare it for the inline CSS rule that creates the border. For example:
<body>
<div style="">
This is the text that has a border around it.
</div>
</body> - 5). Enter the "width" and "height" designators that specify the measurements of the border. Type a number value in pixels (px) after the "width" and "height" as follows:
<div style="width: 150px; height: 150px;">
This is the text that has a border around it.
</div> - 6). Type in a "border" attribute to assign the look of the border line. Enter a value in pixels to specify the width and type in the name of a color. Further, enter a characteristic, such as "solid" or "dotted," to specify how the line appears. To illustrate:
<div style="width: 150px; height: 150px; border: 3px solid red;">
This is the text that has a border around it.
</div> - 7). Save your file with an "HTM" or "HTML" file ending (extension). Launch your Web browser and select the "Open" or "Open File" option under the "File" menu to open your document and view the border around your text.