- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Display Inline Working with CSS
The CSS Display property with value inline renders an element according to content’s width, it does not force a line break. An element with display as inline renders as a <span> element.
Syntax
Following is the syntax for CSS display inline −
Selector { display: inline; }
Example
Let’s see an example of CSS display inline −
<!DOCTYPE html> <html> <head> <title>CSS Display Inline</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; box-sizing: border-box; } input[type="button"] { border-radius: 10px; } .child{ height: 40px; color: white; border: 4px solid black; display: inline; } .child:nth-of-type(1){ background-color: #FF8A00; } .child:nth-of-type(2){ background-color: #F44336; } .child:nth-of-type(3){ background-color: #C303C3; } .child:nth-of-type(4){ background-color: #4CAF50; } .child:nth-of-type(5){ background-color: #03A9F4; } .child:nth-of-type(6){ background-color: #FEDC11; } </style> </head> <body> <form> <fieldset> <legend>CSS-Display-Inline</legend> <div id="container"> <div class="child"></div> <div class="child"></div> <div class="child"></div> <div class="child"></div> <div class="child"></div> <div class="child"></div> </div><br> </body> </html>
Output
This will produce the following output −
Example
Let’s see another example of CSS Display inline −
<!DOCTYPE html> <html> <head> <style> #flex { display: flex; } #none { display: none; } .inline-block { display: inline-block; background-color: mintcream; } .grid { display: grid; background-color: cornflowerblue; } div { margin: 30px; padding: 5px; height: 10px; line-height: 5px; text-align: center; background-color: lightblue; border: 2px solid black; } div > div { background-color: lightpink; border: 2px solid green; } div > div > div { background-color: sandybrown; border: 2px solid darkred; } </style> </head> <body> <div><span id="flex">One</span> <div><span id="none">Two</span> <div> <span class="inline-block">Three</span> <span class="inline-block">Four</span> <div> <span class="grid">Five Six</span> <span class="grid">Sevn Eight</span> </div> </div> </div> </div> </body> </html>
Output
This will produce the following output −
- Related Articles
- Display Inline-Block Working with CSS
- Working with Inline CSS
- Working with CSS Display Property
- Display Inline using CSS
- Working with Display Block in CSS
- Display Inline-Block using CSS
- What is the difference between display: inline and display: inline-block in CSS?
- How to make div elements display inline using CSS?
- How to display paragraph elements as inline using CSS?
- Working with CSS Units
- Working with element for CSS
- Text Indentation Working with CSS
- Word Spacing Working with CSS
- Styling Links Working with CSS
- Text Transformation Working with CSS

Advertisements