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

HTML DOM Style justifyContent Property

Style justifyContent Property

Style Object Reference The Style object

Example

Around the

items of a flexible element, leaving whitespace:

document.getElementById("main".style.justifyContent="space-between";

Try it »


Definition and Usage

justifyContent aligns the items within a flexible container (horizontally) when they do not occupy all the available space on the main axis.

**Tip:** Use the alignContent property to align items on the cross axis (vertically).


Browser support

Internet Explorer Firefox Opera Google Chrome Safari

Firefox, Opera and Chrome support the justify-content property.


Syntax

Returns the justifyContent property:

object

.style.justifyContent

Sets the justifyContent property:

object

.style.justifyContent="flex-start|flex-end|center|space-between|space-around|initial|inherit"

Attribute values

Value Description
flex-start Default value. The items are positioned at the beginning of the container.
flex-end Items are located at the end of the container.
center Items are located at the center of the container.
space-between Items are located in a container with space left between the lines.
space-around Items are located in a container with space left before, between, and after each line.
initial Sets this property to its default value. See initial.
inherit Inherits this property from its parent element. See inherit.

Technical Details

Default value: flex-start
Return Value: A string that represents the justify-content property of an element.
CSS version CSS3

Related Articles

CSS Reference Manual:justify-content Property

HTML DOM STYLE Reference Manual:alignContent Property

HTML DOM STYLE Reference Manual:alignItems Property

HTML DOM STYLE Reference Manual:alignSelf Property


Style Object Reference The Style object