The align attribute sets horizontal alignment of an element (or, on images, how it sits beside text). Classic text values are left, center, right, and justify.
It appeared on many presentational tags (<p>, headings, table cells, <img>, <hr>, and more). For new work, use CSS: text-align, float, and vertical-align.
Deprecated.
Do not use align in new pages. Prefer CSS. Browsers still support it for old content — learn it to read legacy HTML, not to ship it.
Syntax
HTML Syntax
syntax.html
<element align="left | center | right | justify">
Images historically also used top, middle, and bottom (see values below).
Values
Attribute Values
Common values and their modern CSS replacements:
Value
Description
Try it
left
Flush left text, or float image left. Prefer text-align: left / float: left
Toggle the deprecated align attribute on a paragraph. Prefer CSS in real projects.
Legacy demo only. New pages should use text-align instead.
Paragraph
The quick brown fox jumps over the lazy dog. Alignment changes the edges of these lines.
align="center" — prefer text-align: center
Code
HTML Examples
Legacy snippets for study, plus the CSS replacement. Use Try It Yourself for a live editor.
Example 1 — Paragraph Alignment (Legacy)
How old pages centered a heading or paragraph.
HTML
<h1 align="center">How to Carve Wood</h1>
<p align="right">This paragraph hugs the right edge.</p>
<p align="justify">Justified text stretches to both margins when the line is long enough to wrap.</p>
Justified text stretches to both margins when the line is long enough to wrap across the full width of this box.
How It Works
align on the element sets that block’s text alignment.
center / right / justify match the classic print meanings.
Browsers still paint it for compatibility with old documents.
Prefer CSStext-align with the same keywords in new code.
Example 2 — Image Float with align (Legacy)
On <img>, left / right wrapped text beside the image.
HTML
<p>
<img src="/images/codetofun-logo.png" alt="CodeToFun logo" width="80" height="80" align="left">
Text flows around an image aligned to the left. Prefer CSS float: left today.
</p>
One line: learn align for old markup — ship text-align (and friends) instead.
Frequently Asked Questions
It sets horizontal alignment of an element’s content or, on images, how the image sits beside text. Common values are left, center, right, and justify.
Yes. MDN and the HTML living standard treat it as deprecated. Prefer CSS text-align for text, float for image left/right wrapping, and vertical-align for inline image alignment.
Historically many presentational elements: p, div, h1–h6, table parts (tr, td, th), img, hr, iframe, and others listed in the HTML attribute reference.
Use CSS text-align: center on the element (or a parent).
Use CSS float: left (and clear floats as needed). For vertical position in a line of text, use vertical-align.
Yes for reading older pages and emails. Do not use it in new projects.