- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Code Builder
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - border Attribute
The border of an HTML element, such as tables and images, can be specified using the HTML border attribute. You can specify the border's width and color to surround the element. You can provide the border's color using either a hexadecimal color code or a color name, and you can also specify the border's thickness in pixels or as a percentage.
The style and structure of web pages can be improved by using this feature, which is especially helpful for modifying the visual appearance of elements.
Syntax
Following is the syntax of the HTML ‘border’ attribute −
<tag border = "value"></tag>
Example
In the following program, we are using HTML 'border' attribute within <table> tag to set the border of the entire table.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML border attribute</title> </head> <body> <!-- Example of the HTML 'border' attribute --> <h3>Example of the HTML 'border' attribute with table</h3> <p>User details</p> <table border='1'> <tr> <th>S.No</th> <th>Name</th> <th>Age</th> </tr> <tr> <td>1.</td> <td>Revathi</td> <td>22</td> </tr> <tr> <td>2.</td> <td>Sarika</td> <td>22</td> </tr> </table> </body> </html>
When we run the above code, it will generate an output consisting of the table filled with data displayed on the webpage.
Example
Considering the another scenario, where we are going to use the border attribute with the img tag.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML border attribute</title> <style> img { width: 300px; } </style> </head> <body> <!-- Example of the HTML 'border' attribute --> <h3>Example of the HTML 'border' attribute with img</h3> <img src="https://www.tutorialspoint.com/html/images/html-mini-logo.jpg" border='5'> </body> </html>
On running the above code, the output window will pop up displaying the image along with a border applied to it on the webpage.
Example
In this program, we are defining the container for external sources using the ‘object’ element. Then, we use the ‘border’ element within the <object> tag to set the border of the ‘object’ element.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML border attribute</title> <style> object { width: 200px; height: 100px; } </style> </head> <body> <!-- Example of the HTML 'border' attribute --> <h3>Example of the HTML 'border' attribute with object</h3> <object data="https://www.tutorialspoint.com/static/images/simply-easy-learning.png" border='4'>TutorialsPoint</object> </body> </html>
When we run the above code, it will generate an output displaying the image with a border on the webpage.
To Continue Learning Please Login
Login with Google