This example shows three elements with different display styles using Tailwind classes:
- The blue block paragraph takes full width and starts on a new line.
- The green inline span flows inside text without breaking the line.
- The red and yellow inline-block divs sit side by side and have fixed 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, Inline, Inline-block Example</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="p-6">
<p class="block bg-blue-200 p-2 mb-2">This is a block element. It takes full width and starts on a new line.</p>
<p>
This is some text with an <span class="inline bg-green-200">inline element</span> inside it.
The inline element does not break the line.
</p>
<div class="inline-block bg-red-200 p-2 mt-4" style="width: 150px; height: 50px;">
Inline-block element with set width and height.
</div>
<div class="inline-block bg-yellow-200 p-2 ml-2" style="width: 150px; height: 50px;">
Another inline-block next to it.
</div>
</body>
</html>