Key Concepts

Review core concepts you need to learn to master this subject

CSS z-index property

//`element1` will overlap `element2` .element1 { position: absolute; z-index: 1; } .element2 { position: absolute; z-index: -1; }

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.

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: Diagram of block-level elements Bloc…
  3. 3
    One way to modify the default position of an element is by setting its position property to relative. This value allows you to position an element relative to its default static position on the …
  4. 4
    Another way of modifying the position of an element is by setting its position to absolute. When an element’s position is set to absolute all other elements on the page will ignore the element and…
  5. 5
    When an element’s position is set to absolute, 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
    Since static and relative positioned elements stay in the normal flow of the document, when a user scrolls the page (or parent element) these elements will scroll too. And since fixed and absolute …
  7. 7
    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. .blue-box…
  8. 8
    Every HTML element has a default display 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…
  9. 9
    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 width pr…
  10. 10
    The third value for the display property is inline-block. Inline-block display combines features of both inline and block elements. Inline-block elements can appear next to each other and we can sp…
  11. 11
    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 in the conta…
  12. 12
    The float 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, element…
  13. 13
    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: * The position 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