English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
This article introduces how to specify the horizontal alignment of content within a <div> element using the HTML div align attribute, with online examples demonstrating the usage of the HTML div align attribute, browser compatibility, syntax definition, and detailed information about its attribute values, etc.
The parts that will be centered in the document:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML <div> <align> Attribute Usage-Basic Tutorial(oldtoolbag.com)</title> </head> <body> <p>This is a paragraph. The text does not specify alignment.</p> <div align="center" style="border:1px solid red"> This is some text within a div element! </div> <p>This is a paragraph. The text does not specify alignment.</p> </body> </html>Test to see ‹/›
IEFirefoxOperaChromeSafari
All mainstream browsers support the align attribute.
HTML5The <div> align attribute is no longer supported in CSS, please use CSS instead.
The align attribute of <div> in HTML 4.01 has been deprecated. in HTML 4.01.
The align attribute specifies the horizontal alignment of the content within the <div> element.
HTML5The <div> align attribute is no longer supported in CSS, please use CSS instead.
CSS Syntax: <div style="text-align:center">
CSS Example: Reduce the line height in the list
In our CSS tutorial, you can find more abouttext-align attributedetails.
<div align="left|right|center|justify">
Value | Description |
---|---|
left | Left align the content. |
right | Right align the content. |
center | Center align the content. |
justify | Extend the line, so that each line can have an equal length (like in newspapers and magazines). |