🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to CSS Notes
Topic #78

CSS Inline-block


The CSS display: inline-block

The display: inline-block property combines the features of both inline and block elements.

An element with display: inline-block will appear on the same line as other inline or inline-block elements. In addition, you can set the width, height, margin-top, and margin-bottom properties for the element (like block elements).

The following example shows the different behavior of display: inline, display: inline-block and display: block:

Example

  span.a {
  display: inline; /* the default for span */

  padding: 5px;
  border: 2px solid red;
}

span.b {

    display:
  inline-block;
  width: 100px;
  height:
  35px;
  padding: 5px;
  border: 2px
  solid red;
}

  span.c {
  display: block;
  width:
  100px;
  height: 35px;
  padding: 5px;

  border: 2px solid red;
}

Create a Horizontal Navigation Menu

A common use for display: inline-block is to display list items horizontally instead of vertically. The following example creates a horizontal navigation menu:

Example

  .nav {
  background-color: lightgray;
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.nav li {
  display: inline-block;

    font-size: 18px;
  padding:
  15px;
}

CSS Property

Property Description
display Specifies the display behavior (the type of rendering box) of an element

Want to go beyond the notes?

Join CodingNow 2.0's CSS course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

CSS Inline-block – FAQs

Quick answers about learning CSS Inline-block in CSS.

This free note from CodingNow 2.0 explains CSS Inline-block in CSS — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every CSS topic on CodingNow 2.0, including CSS Inline-block, is 100% free with no signup required.
With focused practice, most students grasp CSS Inline-block in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now