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:
- id, class (document-wide identifiers)
- lang (language information), dir (text direction)
- title (element title)
- style (inline style information)
- onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup (intrinsic events)
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 <span> element embedded</span></p>
</div>
</body>
</html>
Comments
No comments have been made yet.
Please login to leave a comment. Login now