Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Style alignSelf Property

Style alignSelf Property

Style Object Reference The Style object

Example

Center-align a certain item inside a flexible element:

document.getElementById("myDIV").style.alignSelf="center";

Try it »


Definition and Usage

The alignSelf property specifies the alignment of a selected item inside a flexible container.

**Note:** The alignSelf property can override the alignItems property of the flexible container.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Firefox, Opera, and Chrome support the alignSelf property.

Syntax

Return the alignSelf property:

object

.style.alignSelf

Set the alignSelf property:

object

.style.alignSelf="auto|stretch|center|flex-start|flex-end|baseline|initial|inherit"

Attribute values

Value Description
auto Default. The element inherits the align-items property of its parent container. If there is no parent container, it is "stretch".
stretch The element is stretched to fit the container.
center The element is located at the center of the container.
flex-start The element is located at the beginning of the container.
flex-end The element is located at the end of the container.
baseline The element is located at the baseline of the container.
initial Sets this property to its default value. See initial.
inherit Inherits this property from its parent element. See inherit.

Technical Details

Default value: auto
Return Value: A string representing the align-self property of the element.
CSS version CSS3

Related Articles

CSS Reference Manual:align-self Property

HTML DOM STYLE Reference Manual:alignContent Property

HTML DOM STYLE Reference Manual:alignItems Property


Style Object Reference The Style object