NOTICE: This website is no longer updated or supported - as such many of the techniques used to build it may seem antiquated in the modern day. It is preserved for historical reasons only.

HTML XHTML The Complete Reference
home » reference » appendix a » html element reference

<center> (Center Alignment)


This element causes the enclosed content to be centered within the margins currently in effect. Margins are either the default page margins or those imposed by overriding elements such as tables.

Syntax (Transitional Only)


<center
class="class name(s)"
dir="ltr | rtl"
id="unique alphanumeric identifier"
lang="language code"
style="style information"
title="advisory text"
</center>

Attributes Defined by Internet Explorer


accesskey="key" (5.5)
contenteditable="false | true | inherit" (5.5)
disabled="false | true" (5.5)
hidefocus="true | false" (5.5)
language="javascript | jscript | vbs | vbscript" (4)
tabindex="number" (5.5)
unselectable="on | off" (5.5)

Standard Events


onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup

Events Defined by Internet Explorer


onactivate, onbeforeactivate, onbeforecopy, onbeforecut, onbeforedeactivate, onbeforeeditfocus, onbeforepaste, onblur, oncontextmenu, oncontrolselect, oncopy, oncut, ondeactivate, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onfocus, onfocusin, onfocusout, onhelp, onlosecapture, onmouseenter, onmouseleave, onmousewheel, onmove, onmoveend, onmovestart, onpaste, onpropertychange, onreadystatechange, onresizeend, onresizestart, onselectstart, ontimeerror

Example


<center>This is in the center of the page.</center>

Compatibility


HTML 2, 3.2, 4, 4.01, and XHTML 1.0 (transitional)
Internet Explorer 2, 3, 4, 5, 5.5, 6
Netscape 1, 1.1, 2, 3, 4, 4.5-4.8, 6, 7
Opera 4-7

Notes


The <center> element defined by the W3C is a shorthand notation for <div align="center">. The strict version of HTML 4.01 does not include the <center> element.

The strict versions of HTML and XHTML do not include the center element, but it is easily imitated with the text-align CSS property.

HTML 3.2 does not support any attributes for this element.

(X)HTML Elements
CSS Properties
Previous: caption Next: cite
< Home | About | Chapters | Examples | Errata | Reference | Site Map >