This page shows three types of display:
- Block element takes full width and starts on a new line.
- Inline elements flow inside text on the same line.
- Inline-block elements sit side by side but keep block features like width and height.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Block vs Inline vs Inline-block</title>
<style>
.block {
display: block;
background-color: #a0d8f0;
margin-bottom: 0.5rem;
padding: 0.5rem;
}
.inline {
display: inline;
background-color: #f0c0a0;
padding: 0.5rem;
}
.inline-block {
display: inline-block;
background-color: #a0f0c0;
width: 8rem;
height: 2rem;
line-height: 2rem;
text-align: center;
margin-right: 0.5rem;
}
</style>
</head>
<body>
<div class="block">I am block - full width, new line</div>
<span class="inline">I am inline - flow inside text</span>
<span class="inline">I am also inline</span>
<br />
<div>
<div class="inline-block">Inline-block 1</div>
<div class="inline-block">Inline-block 2</div>
<div class="inline-block">Inline-block 3</div>
</div>
</body>
</html>