以下示例演示了块级和行内框。两个带有绿色边框的段落元素是块级元素,它们一个在另一个下方显示。
第一句话还包含一个带有蓝色背景的 span 元素。这是一个行内级元素,因此它在句子中原位显示。
<div class="box">
<p>
One <span>November</span> night in the year 1782, so the story runs, two
brothers sat over their winter fire in the little French town of Annonay,
watching the grey smoke-wreaths from the hearth curl up the wide chimney.
Their names were Stephen and Joseph Montgolfier, they were papermakers by
trade, and were noted as possessing thoughtful minds and a deep interest in
all scientific knowledge and new discovery.
</p>
<p>
Before that night—a memorable night, as it was to prove—hundreds of millions
of people had watched the rising smoke-wreaths of their fires without
drawing any special inspiration from the fact.
</p>
</div>
body {
font: 1.2em sans-serif;
}
p {
border: 2px solid green;
}
span {
background-color: lightblue;
}