Long description

Back

Essential solutions.

Centering an element horizontally within a container.

Lines of code:

Set 1: Line 1 at indentation level 0: open angle bracket div id equals element close angle bracket content open angle bracket forward slash div close angle bracket.

Set 2:

Line 1 at indentation level 0: hash element open curly bracket .

Line 2 at indentation level 1: margin colon 0 auto semicolon.

Line 3 at indentation level 1: width colon 200px semicolon forward slash asterisk some value asterisk forward slash.

Line 4 at indentation level 0: close curly bracket.

The image has a color bar of various colors.

Note: Set 2 result in browser Element. In chapter 7, you will learn how to use flexbox layout to position an element horizontally and vertically within a container.

Back