These two elements, in combination with style sheets, are used to define the main layout of the content.

A <div> is a block level element, meaning it starts with a new line and usually groups larger structures together.

A <span> is an inline level element and it starts on the text level. It generally may contain only data such as text but not other block level elements.

Syntax:

<div></div>, <span></span>

Attributes:

Example

HTML grouping elements:

x
 
<html>
<head>
<title>HTML tutorial</title>
</head> 
<body>
<div class="content_wrap">
<p>paragraph #1</p>
<p>paragraph #2 <span style="font-weight:bold">with &lt;span&gt; element embedded</span></p>
</div>
</body>
</html>

 

›› go to examples ››