Css inline block

    inline block





1.display:inline-block

display:inline-block the top and bottom margins/paddings are respected, but wit display: inline they are not.Compared to display: block, the major difference is that display: inline-block does not add a line 14 <mead> break after the element, so the element can sit next to other elements.

Display inline - block

 Example 

 <!DOCTYPE html>

 <html>

 <head> 

 <style>

 nav {

 background-color: lightblue

list-style-type: none;

  text-align: center;

 margin: 0; 

padding: 0; 

}

.nav li {

 display: inline-block;

 font-size: 30px; 

padding: 30px;

Margin:20px;

}

 </style>

</head>

 <body>

 <h1>display: inline-block</h1>

 <ul class="nav">

 <li><a href="#home">Home</a></li>

<li><a href="#about">Projects</a></li> 

 <li><a href="#clients">Clients</a></li> 

<li><a href="#contact">Contact</a></li>

 </ul>

</body>

 </html>

display:inline-block

 output

 

Inline block




2.Demonstration 

(inherit property value)


Demonstration

 Example 

<!DOCTYPE html>

<html>

<head>

<style>

body { display: inline; }

 p{ display: inherit;}

</style> </head>

<body>

<p>The two paragraphs generates inline boxes, </p> <p>no distance between the two elements.</p>

</body>

</html>


Demonstration 

output


Demonstration inherit property use



3.Flex-direction property 

flex-direction property specifies to the direction for the flexible. flex-direction  element is not a flexible item, the flex-direction property.

Flex-direction property 

Example 


<html>
<head>
<style>

#main {
width: 300px; 
height: 200px;
border: 1px solid #c3c3c3;
display:-webkit-flex: / Safari "/ -webkit-flex-direction:row -reverse; /* Safari 6.1+ "/ display: flex: flex-direction: row-reverse;
#main div {
width: 50px;
height: 50px;
</style>
 </head>
 <body>
<h1>The flex-direction Property</h1>

<div id="main">
<div style="background-color:coral;">A</div>  
<div style="backgroundcolor:lightblue:">B</div>

<div style="background-color:khaki;">C</div>

<div style="background-color:pink;">D</div>

<div style="background-color:lightgrey;">E</div> <div style="background-color:lightgreen:;">F</div>

 </div>
</body>
</html>

Flex-direction property 

output 


Flex-direction property




READ MORE :-

css column gap property program

split a background into 2 color

how to apply image tag in html

Comments

Popular posts from this blog

What Is CSS Text Color in 2026

CSS Padding Property Explained

CSS Outline Color Property in 2026