Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Understanding Block, Inline, and Inline-Block Elements | The CSS Box Model & Spacing Elements
CSS Fundamentals
course content

Conteúdo do Curso

CSS Fundamentals

CSS Fundamentals

1. Getting Started with CSS
2. Styling Text in CSS
3. The CSS Box Model & Spacing Elements
4. Mastering Flexbox for Layouts
5. Adding Decorative Effects with CSS

book
Understanding Block, Inline, and Inline-Block Elements

Elements in HTML can be classified as inline or block based on their behavior.

  • Inline elements stay on the same line as other elements, only taking up as much width as needed. Examples: <a>, <span>, <img>, <input>;
  • Block elements start on a new line and take up the full width of their container. Examples: <div>, <h1><h6>, <p>, <ul>, <li>.

Block Elements

Block elements occupy the entire width of their container and always start on a new line. They can be styled using CSS properties like width, height, margin, padding, and border. Common examples of block elements include <div>, <p>, <ul>, and <li>.

html

index.html

css

index.css

copy

Inline Elements

Inline elements stay on the same line as other elements and only occupy the width needed for their content. Unlike block elements, inline elements cannot have width, height, margin, or padding values assigned, but border can still be applied. Examples of inline elements include <a>, <span>, <img>, and <input>.

html

index.html

css

index.css

copy

Inline-block Elements

Inline-block elements do not start on a new line but combine the styling flexibility of block elements. They can be customized using CSS properties like width, height, margin, padding, and border. Examples of inline-block elements include <button>, <select>, and <textarea>.

html

index.html

css

index.css

copy

1. What is the main difference between block and inline elements?

2. Which of the following is an example of a block element?

question mark

What is the main difference between block and inline elements?

Select the correct answer

question mark

Which of the following is an example of a block element?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 7
Sentimos muito que algo saiu errado. O que aconteceu?
some-alt