HTML Attributes
HTML align Attribute
The align attribute used to control horizontal alignment of elements, but it is deprecated in HTML5.
The align Attribute (Deprecated)
⚠️
The align attribute is deprecated in HTML5 and must not be used in new code. Browsers may still honour it, but you should control alignment with CSS instead.
Historically, align set the horizontal (and sometimes vertical) positioning of content for elements such as <img>, <table>, <td>, <div>, <p> and headings. Values like left, right and center floated or aligned the element within its container.
Syntax (Legacy)
<!-- Deprecated: do not use -->
<img src="logo.png" align="right" alt="Company logo">
<p align="center">Centered text</p>The Modern CSS Replacement
<img src="logo.png" style="float: right" alt="Company logo">
<p style="text-align: center">Centered text</p>| Old align value | Modern CSS equivalent |
|---|---|
| align="left" | text-align: left or float: left |
| align="right" | text-align: right or float: right |
| align="center" | text-align: center or margin: 0 auto |
| align="justify" | text-align: justify |
💡
For centering block-level elements, use CSS such as margin: 0 auto or modern layout tools like Flexbox and Grid instead of the align attribute.
