Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Working with Inline Elements | The CSS Box Model & Spacing Elements
CSS Fundamentals

bookWorking with Inline Elements

Inline elements stay on a single line and wrap to the next line when space runs out. This behavior is controlled by the CSS property display: inline.

Key points about inline elements:

  • They default to display: inline;
  • Their width and height are determined by their content and cannot be explicitly set;
  • Only horizontal properties like padding, margin, and border can be applied.

Let's examine an example where some styles impact the element, while others do not, within the CSS file:

index.html

index.html

index.css

index.css

copy
Note
Study More

By default,Β inlineΒ elements have a gap on the right side; forΒ imgΒ elements, this gap is at the bottom. This space is not attributed toΒ paddingΒ orΒ margin. Instead, it's an inherent blank space added by browsers to ensure a distance between each element.

index.html

index.html

copy
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 3. ChapterΒ 9

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Can you explain why vertical margins and paddings don't affect inline elements?

What are some common inline elements besides the <a> tag?

How can I make an inline element behave like a block element?

Awesome!

Completion rate improved to 2.56

bookWorking with Inline Elements

Swipe to show menu

Inline elements stay on a single line and wrap to the next line when space runs out. This behavior is controlled by the CSS property display: inline.

Key points about inline elements:

  • They default to display: inline;
  • Their width and height are determined by their content and cannot be explicitly set;
  • Only horizontal properties like padding, margin, and border can be applied.

Let's examine an example where some styles impact the element, while others do not, within the CSS file:

index.html

index.html

index.css

index.css

copy
Note
Study More

By default,Β inlineΒ elements have a gap on the right side; forΒ imgΒ elements, this gap is at the bottom. This space is not attributed toΒ paddingΒ orΒ margin. Instead, it's an inherent blank space added by browsers to ensure a distance between each element.

index.html

index.html

copy
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 3. ChapterΒ 9
some-alt