<CENTER...>

All lines of text between the begin and end of the <CENTER> element are centred between the current left and right margins.

<CENTER>All this text would be centred in the page</CENTER>

NOTE : Most browsers will internally work-round this element to produce the desired format, but it is an element introduced by Netscape authors.

Internet Explorer (4.0 and above) also support the use of the TITLE attribute. This can be used for informational purposes, with Internet Explorer treating the value of the TITLE attribute as a 'ToolTip' which is displayed when the reader passes their mouse over the contents of the <CENTER> element. For example, adding :

. . .TITLE="Some centered text"

to the above example, the section displays as :

All this text would be centred in the page

displaying the ToolTip when the mouse pauses on the text.

LANG="language setting"
The LANG attribute can be used to specify what language the <CENTER> element is using. It accepts any valid ISO standard language abbreviation (for example "en" for English, "de" for German etc.) For more details, see the Document Localisation section for more details.

LANGUAGE="Scripting language"
The LANGUAGE attribute can be used to expressly specify which scripting language Internet Explorer 4.0 uses to interpret any scripting information used in the <CENTER> element. It can accept values of vbscript, vbs, javascript or jscript. The first two specify the scripting language as Visual Basic Script, the latter two specify it as using Javascript (the default scripting language used if no LANGUAGE attribute is set.

CLASS="Style Sheet class name"
The CLASS attribute is used to specify the <CENTER> as using a particular style sheet class. For example, a style sheet class defined as:

<STYLE TYPE="text/css">
.RedQuote {color : #FF0000}
</STYLE>

could then be referenced as:

<CENTER CLASS="RedQuote">All this text would be centred in the page</CENTER>

and would be displayed in red. See the Style Sheets overview for more information and style sheet settings.

STYLE="In line style setting"
As well as using previously defined style sheet settings, the <CENTER> element can have in-line stylings attached to it. For example:

<CENTER STYLE="{color : #FF0000}">All this text would be centred in the page</CENTER>

would display exactly as the above example. See the Style Sheets section for more details about style sheet settings.

ID="Unique element identifier"
The ID attribute can be used to either reference a unique style sheet identifier, or to provide a unique name for the <CENTER> element for scripting purposes. Any <CENTER> element with an ID attribute can be directly manipulated in script by referencing its ID attribute, rather than working through the All collection to determine the element. See the Scripting introduction topic for more information.


Every <CENTER> element in a document is an object that can be manipulated through scripting. Note that scripting of the <CENTER> element/object is only supported by Internet Explorer 4.0 in its Dynamic HTML object model. Netscape does not support direct scripting of the <CENTER> element at all.

<CENTER...> Properties
The <CENTER...> element/object supports all of the standard Dynamic HTML properties (i.e. className, document, id, innerHTML, innerText, isTextEdit, lang, language, offsetHeight, offsetLeft, offsetParent, offsetTop, offsetWidth, outerHTML, outerText, parentElement, parentTextEdit, sourceIndex, style, tagName and title). Details of these can be found in the standard Dynamic HTML properties topics.

<CENTER...> Methods
The <CENTER...> element/object supports all of the standard Dynamic HTML methods (i.e. click, contains, getAttribute, insertAdjacentHTML, insertAdjacentText, removeAttribute, scrollIntoView and setAttribute). Details of these can be found in the standard Dynamic HTML Methods topics.

<CENTER...> Events
The <CENTER...> element/object supports all of the standard Dynamic HTML events (i.e. onclick, ondblclick, ondragstart, onfilterchange, onhelp, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup and onselectstart). Details of these can be found in the standard Dynamic HTML events topics.