Key Concepts

Review core concepts you need to learn to master this subject

CSS display property

.element { display: block; }

The display property declares how an element should be rendered. The three common values of this property are block, inline and inline-block among several other values.The block is the default value for various elements including heading elements (<h1> through <h6>), <p>, <div>, and <footer>. The inline is the default value for some elements,such as <em>, <strong>, and <a>. The inline-block is the default value for <img> tags.

CSS display property

.element { display: block; }

The CSS display property determines the type of render block for an element. The most common values for this property are block, inline, and inline-block.

Block-level elements take up the full width of their container with line breaks before and after, and can have their height and width manually adjusted.

Inline elements take up as little space as possible, flow horizontally, and cannot have their width or height manually adjusted.

Inline-block elements can appear next to each other, and can have their width and height manually adjusted.

CSS z-index property

.element { display: block; }

The CSS z-index property specifies how far back or how far forward an element will appear on a web page when it overlaps other elements.

The z-index property uses integer values, which can be positive or negative values. The element with the highest z-index value will be at the foreground, while the element with the lowest z-index value will be at the back.

CSS position: absolute

.element { display: block; }

The value absolute for the CSS property position enables an element to ignore sibling elements and instead be positioned relative to its closest parent element that is positioned with relative or absolute. The absolute value removes an element entirely from the document flow. By using the positioning attributes top, left, bottom and right, an element can be positioned anywhere as expected.

CSS position: relative

.element { display: block; }

The value relative of the CSS position property enables an element to be positioned relative to where it would have originally been on a web page. The offset properties can be used to determine the actual position of the element relative to its original position. Without the offset properties, this declaration will have no effect on its positioning, it will act as the default value static of the position property.

CSS float property

.element { display: block; }

The CSS float property determines how far left or how far right an element should float within its parent element. The value left floats an element to the left side of its container and the value right floats an element to the right side of its container. For the property float, the width of the container must be specified or the element will assume the full width of its containing element.

The CSS clear property

.element { display: block; }

The CSS clear property specifies how an element should behave when it bumps into another element within the same containing element.The clear is usually used in combination with elements having the CSS float property. This determines on which sides floating elements are allowed to float.

CSS Display and Positioning
Lesson 1 of 1
  1. 1

    A browser will render the elements of an HTML document that has no CSS from left to right, top to bottom, in the same order as they exist in the document. This is called the flow of elements in H…

  2. 2

    Take a look at the block-level elements in the image below: Block-level elements like these boxes create a block the full width of their parent elements, and they prevent other elements fro…

  3. 3

    One way to modify the default position of an element is by setting its […] property to […] . This value allows you to position an element relative to its default static position on the we…

  4. 4

    Another way of modifying the position of an element is by setting its position to […] . When an element’s position is set to […] all other elements on the page will ignore the element and…

  5. 5

    When an element’s position is set to […] , as in the last exercise, the element will scroll with the rest of the document when a user scrolls. We can fix an element to a specific position on …

  6. 6

    When boxes on a web page have a combination of different positions, the boxes (and therefore, their content) can overlap with each other, making the content difficult to read or consume. […] …

  7. 7

    Every HTML element has a default […] value that dictates if it can share horizontal space with other elements. Some elements fill the entire browser from left to right regardless of the size of…

  8. 8

    Some elements are not displayed in the same line as the content around them. These are called block-level elements. These elements fill the entire width of the page by default, but their […] …

  9. 9

    The third value for the […] property is […] . Inline-block display combines features of both inline and block elements. Inline-block elements can appear next to each other and we can specif…

  10. 10

    So far, you’ve learned how to specify the exact position of an element using offset properties. If you’re simply interested in moving an element as far left or as far right as possible on the page,…

  11. 11

    The […] property can also be used to float multiple elements at once. However, when multiple floated elements have different heights, it can affect their layout on the page. Specifically, eleme…

  12. 12

    Great job! In this lesson, you learned how to control the positioning of elements on a web page. Let’s review what you’ve learned so far: 1. The […] property allows you to specify the positio…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo