Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

Learn CSS: Display (Inline-block) Properties in CSS

Understand Learn CSS: Display (Inline-block) Properties in CSS with clear explanations, practical examples, and useful tips. This updated guide covers the...

Table of Contents

Learn CSS: Display (Inline-block) Properties in CSS is easier to understand when the core ideas are paired with practical examples. The sections below explain the topic clearly, highlight useful steps, and point out details that can prevent common errors.

Can notice that, some HTML tags like

,

,

always start with a new line and have a line length stretching 100% of the web page, while other HTML tags like , Learn CSS: Display (Inline-block) Properties in CSS example image 1 or it is typically placed one after another on the same line. Why is there such a difference? Find the answer through a lesson about the value of the display attribute right away.

Simply answered, this difference is due to different display values: Block and Inline.

The values of the Display attribute

Display: inline value

Inline is a way to display on a row and the width of that tag will depend on the content of the tag, so many tags can be on the same row. However, inline cannot use the attributes width, height and top-bottom margin. The HTML tags displayed inline default are,,,, .

 span.a { 
  display: inline; /* m?c ??nh v?i span, a, strong, b, i. */ 
  width: 100px; 
  height: 100px; 
  padding: 5px; 
  border: 1px solid blue; 
  background-color: #DB7093; 
 } 

Learn CSS: Display (Inline-block) Properties in CSS example image 2

Display properties

display: inline

You can become part of TipsMake.com by submitting an article, Experience your technology on the content management team of the social network via info@tipsmake.com email address info@meta.com.vn or register an account and post directly on TipsMake.com.

In this example, the width and height attributes are not available, span tags are on the same line side by side, some attributes apply to affect the content on other lines.

Display value: block

Block is a display that always starts with a new line and is as wide as 100% of the page width. So when you use this card, although the content is short, the other tags at the bottom are still in a different line. The difference of this tag is that it can use the width and height attributes . HTML tags that display the default block are:

,

,

come

,
,,,
 span.b { 
  display: block; 
  width: 100px; 
  height: 100px; 
  padding: 5px; 
  border: 1px solid blue; 
  background-color: #DB7093; 
 } 

Learn CSS: Display (Inline-block) Properties in CSS example image 3

Display properties

display: block

You can become part of TipsMake.com by submitting an article, Experience your technology on the content management team of the social network via info@tipsmake.com email address info@meta.com.vn or register an account and post directly on TipsMake.com.

In this example, the width and height attributes are usable, but because of the fixed size, the longer content will overflow.

Display: inline-block value

Inline-block is a way of displaying the combination of both ways, moving the element to display on the same row but it still inherits the properties of the block.

 span.c { 
  display: inline-block; 
  width: 100px; 
  height: 100px; 
  padding: 5px; 
  border: 1px solid blue; 
  background-color: #DB7093; 
 } 

Learn CSS: Display (Inline-block) Properties in CSS example image 4

Display properties

display: inline-block

Update trends, discover, Latest research on science and technology.

Compared to display: inline, inline-block display can use the attributes width, height and top-bottom margin.

Compared to display: block, inline-block display does not break the line after the end of the tag, so the cards can be placed side by side.

Display: inline-block is mainly used for displaying the navigation list horizontally:

 .nav { 
  background-color: yellow; 
  list-style-type: none; 
  text-align: center; 
  padding: 0; 
  margin: 0; 
 } 
 
 .nav li { 
  display: inline-block; 
  font-size: 20px; 
  padding: 20px; 
 } 

Learn CSS: Display (Inline-block) Properties in CSS example image 5

Website Administration Network

You can become part of TipsMake.com by submitting an article, Experience your technology on the content management team of the social network Assembly via email info@tipsmake.com or register an account and post directly on TipsMake.com.

  • Technology village
  • Technology
  • Science
  • Life

By default, list items are displayed vertically. In this example, we use display: inline-block to display them horizontally (side by side).

Note: If you resize the browser window, the links will automatically pause when the content is longer than the web width.

Previous lesson: FLOAT and CLEAR properties in CSS

Next: Align - Align in CSS

FAQ

What should you know about the values of the Display attribute Display: inline value?

Inline is a way to display on a row and the width of that tag will depend on the content of the tag, so many tags can be on the same row. However, inline cannot use the attributes width, height and top-bottom margin. The HTML tags displayed inline default.

What should you know about display properties display: inline You can become part of TipsMake.com by submitting an article, Experience your technology on the content management team of the social network via info@tipsmake.com email address info@meta.com.vn or register an account and post directly on TipsMake.com. In this example, the width and height attributes are not available, span tags are on the same line side by side, some attributes apply to affect the content on other lines. Display value: block?

Block is a display that always starts with a new line and is as wide as 100% of the page width. So when you use this card, although the content is short, the other tags at the bottom are still in a different line. The difference of this tag is that it can use.

What should you know about come , ,,, span.b { display: block; width: 100px; height: 100px; padding: 5px; border: 1px solid blue; background-color: #DB7093; } Display properties display: block You can become part of TipsMake.com by submitting an article, Experience your technology on the content management team of the social network via info@tipsmake.com email address info@meta.com.vn or register an account and post directly on TipsMake.com. In this example, the width and height attributes are usable, but because of the fixed size, the longer content will overflow. Display: inline-block value?

Inline-block is a way of displaying the combination of both ways, moving the element to display on the same row but it still inherits the properties of the block.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.