The display:inline-block property is used to show an element in the inline-level block container. It converts the block of elements into an inline element. Use height and width property to set an inline element. The display property is used to prevent a line break of a list of items.
Syntax:
element {
display:inline-block;
}
Example:
<!DOCTYPE html> <html> <head> <title>preventline break in list items</title> <style> li { display:inline-block; text-decoration:underline; } h1 { color:green; } h1, h2 { text-align:center; } body { width:70%; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>display:inline-block;</h2> <b>Subjects Of Computer science:</b> <ul> <li>Computer Network</li> <li>Operating System </li> <li>Data Structure using C</li> <li>Object Oriented Programming Concepts</li> <li>Digital Electronics</li> </ul> </body> </html> |
Output:

Supported Browsers: The browser supported by CSS display property are listed below:
- Apple Safari 3.1
- Google Chrome 4.0
- Firefox 3.0
- Opera 7.6
- Internet Explorer 8.0
Recommended Posts:
- How to remove all line breaks from a string using JavaScript?
- How to remove line breaks from the string in PHP?
- How to add line breaks to an HTML textarea?
- How to prevent text in a table cell from wrapping using CSS?
- How to prevent parents of floated elements from collapsing in CSS?
- How to prevent overriding using fake namespace in JavaScript ?
- How to prevent overriding using Immediately Invoked Function Expression in JavaScript ?
- How to set vertical space between the list of items using CSS ?
- How to prevent column break within an element?
- How to prevent inline-block divs from wrapping ?
- How to prevent XSS with HTML/PHP ?
- Prevent System from Entering Sleep mode in ElectronJS
- How to prevent browser to remember password in HTML ?
- How to prevent dragging of ghost image ?
- How to prevent sticky hover effects for buttons on touch devices ?
- Use of :even and :odd pseudo-classes with list items in CSS
- How to read a file line by line using node.js ?
- CSS | align-items Property
- CSS | Ordering Flex Items
- CSS place-items Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Kirti_Mangal


