Professional Documents
Culture Documents
Block-level Elements
Block-level Elements
A block-level element always starts on a new line, and the browsers
automatically add some space (a margin) before and after the element.
The <div> tag is used as a container for HTML elements - which can
be then styled with CSS or manipulated with JavaScript.
Any type of content can be put inside the <div> tag, including other
elements
Important note: By default, browsers always place a line break before
and after the <div> element.
HTML <Div> Element
HTML <div> element is one of the most powerful elements that have
much applicability in web design.
i. HTML <div> element can be used as follows:
ii. It can be used to represent a bloc of the structure of an HTML
document
iii. It can be used to form cascaded blocs that represent the
substructure of an HTML document
iv. It can be crafted to design the layout of a web page thereby
structuring the ‘look and feel’ of a web page
v. The <div> element allows many other elements within its bloc.
HTML <Div> Element
<div> Web page </div> represents a bloc.
Web page
HTML <Div> Element
<div>
<div>
Div 1
</div>
<div>
Div 2
</div>
</div>
Div 1
Div 2
HTML <Div> Element
<div>
<div>
<p> Web page </p>
</div>
<div>
<h1> Website<h1>
</div>
</div>
Web page
Website
HTML <Div> Element Attributes
HTML <div> has attributes that extend its functionality
<div name=“value”>
The purpose is to enhance the behaviour of the
div element
</div>
HTML <Div> Element Attributes
<div id=“container”>
The id attribute provides a unique identity for the div element so
that it can dynamically be manipulated to enhance its
behaviour
</div>
HTML <Div> Element Attributes
</div>
HTML <Div> Element Attributes
<div style="color:blue;text-align:center”>
The style attribute here specifies the background colour of the
container.
</div>
The div element takes every global attribute to enhance its usability
14