HTML <div> alignAttribute

HTML div 标签参考手册HTML <div> Tag

Examples

A section in the document is center-aligned:

<div align="center">
This is some text!
</div>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the align attribute.


Definition and Usage

The align attribute of <div> is no longer supported in HTML5. Use CSS instead.

The align attribute of <div> is deprecated in HTML 4.01. in HTML 4.01.

The align attribute specifies the horizontal alignment of the content in a <div> element.


Compatibility Notes

The align attribute of <div> is no longer supported in HTML5. Use CSS instead.

CSS syntax: <div style="text-align:center">

CSS example: Reduce line height in a list.

In our CSS tutorial, you can find more aboutthe text-align propertydetails.


Syntax

<div align="left|right|center|justify">

Attribute Values

Value Description
left Aligns the content to the left.
right Aligns the content to the right.
center Aligns the content to the center.
justify Stretches the lines so that each line has equal length (like in newspapers and magazines).


HTML div 标签参考手册HTML <div> Tag Other Extensions