
- HTML Tutorial
- HTML - Home
- HTML - Roadmap
- HTML - Introduction
- HTML - History & Evolution
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Frames
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Code Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Table Headers & Captions
- 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 Color Names & Values
- HTML - Color Names
- HTML - RGB & RGBA Colors
- HTML - HEX Colors
- HTML - HSL & HSLA Colors
- HTML - HSL Color Picker
- 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 - Document Object Model (DOM)
- 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 Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Character 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 - align Attribute
HTML algin attribute is used to specify the alignment (center, left or right) of content within an HTML element.
However, in modern HTML, the align attribute has been deprecated in favor of using CSS for layout and alignment. CSS is the standard way for styling and positioning elements in modern web development because it offers more exact control over alignment and display.
Syntax
<tag align = "value"></tag>
Applies On
Below listed elements allow using of the HTML align attribute.
Element | Description |
---|---|
<img> | HTML <img> tag is used to append image in document. |
<table> | HTML <table> tag allow us to put data in a organized way by providing row and column facility. |
<iframe> | HTML <iframe> is an inline frame that allows us to embed another document within the current HTML document. |
<caption> | HTML <caption> tag is used to specify a caption for the table element. |
<col> | HTML <col> tag is used to offer information about columns. |
<applet> | HTML <applet> tag is used for embedding a Java applet within an HTML document. |
<colgroup> | HTML <colgroup> tag is used to describe the collection of one or more columns in a table for formatting. |
<hr> | HTML <hr> tag is used to create a horizontal line on the webpage. |
<legend> | HTML <legend> tag is used to specify the caption of fieldset element. |
<tbody> | HTML <tbody> tag is used to create a separate semantic block in an HTML table, which defines the table's body content. |
<td> | HTML <td> tag is used to define the data cell of the table and used as a child element of tr element. |
<tfoot> | HTML <tfoot> tag is used to group footer content in an HTML table. |
<th> | HTML <th> tag designates the header cell for HTML tables. |
<thead> | HTML <thead> tag is used to group the header content of HTML table |
<tr> | HTML <tr> tag is used to define each row in table. |
Examples of HTML align attribute
In the following examples, we discuss different ways how we can use algin attribute.
Align attribute with h1 and p tag
The below code demonstrate how h1 and p tag can be aligned using algin attribute
<!DOCTYPE html> <html lang="en"> <head> <title>HTML align attribute</title> </head> <body> <!--example of the align attribute--> <h1 align="left">This is h1 heading.</h1> <p align="center">Text within the p tag.</p> </body> </html>
Align attribute with div tag
Consider another scenario, where we are going to use the align attribute with the div element.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML align attribute</title> <style> div { color: green; font-weight: bolder; } </style> </head> <body> <!--example of the align attribute--> <div align="right"> <p> Text within the p tag(it will display the right side of the screen view because we have used align = "right"). </p> </div> </body> </html>
Align attribute with form tag
Let's look at the following example, where we are going to use align attribute with the form.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML align attribute</title> <style> form { width: 300px; height: 210px; background-color: rgb(21, 114, 185); color: white; border-radius: 10px; } form button { width: 100px; padding: 5px; } </style> </head> <body> <!--example of the align attribute--> <form align="center"> <h1 align="center">Login</h1> Username: <input type="text"> <br> <br> Password:<input type="password"> <br> <br> <button>Login</button> </form> </body> </html>
Supported Browsers
Attribute | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
align | Yes | Yes | Yes | Yes | Yes |