Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

Inline-Block Elements

Sometimes we want the best of both: elements that line up in a row like inline elements, but that we can size like blocks. That is what the value inline-block does. On the outside, such an element behaves like an inline one: it sits in a line next to other elements, and when there's no room left in the line, it moves to the next one. On the inside, it's a block: width, height, padding and all margins work on it.

Buttons (button) are inline-block by default. That is why they can stand in a row next to each other, and we can still set their size.

The breeds at the bottom of the page are styled as cards with a width, padding and a border. As list items, though, they are stacked below each other. Let's put them in a row.

Instructions

  1. 1

    In the rule for #breeds li, add display: inline-block. The cards line up in a row and keep their width, padding and border. (With inline, their width would be ignored.)

  2. 2

    Inline-block elements are placed in a line like words, so we can align them like text. In the rule for #breeds ul, add text-align: center. The cards move to the middle of the page.

Back

3/10

  1. 1. Normal Flow and Block Elements
  2. 2. Inline Elements
  3. 3. Inline-Block Elements
  4. 4. Hiding Elements
  5. 5. Relative Position
  6. 6. Absolute Position
  7. 7. Absolute Inside Relative
  8. 8. Fixed Position
  9. 9. Sticky Position
  10. 10. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.