Block and inline 3
Applying display: inline-block
.
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Block and inline boxes 3</title>
<style>
body {
font: 80% arial, helvetica, sans-serif;
}
h1 {
font-size: 1.5em;
}
h2 {
font-size: 1em;
}
code {
font-family: courier;
}
#example2, #example3 {
background: #ccc;
border: 2px solid black;
}
span {
background: white;
display: inline;
border: 0.5em solid red;
padding: 1em;
margin: 0.5em;
}
span.altern8 {
background: #5b5;
}
#example3 span {
display: inline-block;
}
</style>
</head>
<body>
<h1>Block and inline boxes (with padding, border and margin)</h1>
<p>Each of these examples contains the same HTML, but the elements in the first are set to <code>display: inline</code> and the elements in the second are set to <code>display: inline-block</code>.</p>
<h2>Inline</h2>
<p id="example2"><span>This</span><span class="altern8">That</span><span>The Other</span><span class="altern8">4</span></p>
<h2>Inline-Block</h2>
<p id="example3"><span>This</span><span class="altern8">That</span><span>The Other</span><span class="altern8">4</span></p>
<!-- Link back to HTML Dog: -->
<p><a href="http://www.htmldog.com/examples/"><img src="http://www.htmldog.com/badge1.gif" alt="HTML Dog"></a></p>
</body>
</html>