Understanding Block-Level Elements
Description
block
value creates a block-level element, whick creates a new line
before and after the element,
Example
The p element, which marks a paragraph, includes the block value for the display property in its default style convention, but you may apply this value to any element.
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
p {<!-- ww w . j a v a 2s . c o m-->
border: medium solid black
}
span {
display: block;
border: medium double black;
margin: 2px;
}
</style>
</head>
<body>
<p>This is a test.</p>
<p>This is a test.
<span>This is a test</span>.
This is a test.
</p>
</body>
</html>
A span element which is by default an inline element and can also have block style.
Example 2
You can see the different between the block and inline element in the following code.
<html>
<body>
<h1>Block-Level Elements</h1>
<p>
<strong>Block-level elements</strong> start on a new line. The
<code><h1></code>
and<!--from w w w .j a va2s . co m-->
<code><p></code>
elements will not sit on the same line.
</p>
<p>The inline elements flow with the rest of the text.</p>
</body>
</html>