What is grouping in HTML ?
Last Updated :
27 Aug, 2021
Grouping plays a vital role in our web page because it helps the developer to target specific classes and id which makes it easier to position, style, or manipulate the web page with the help of HTML, CSS, or JavaScript.
Grouping can be performed with the help of various tags such as <div>, <header>, <footer>, and <section>.
HTML <div>: It is a block-level tag that groups various HTML tags into a single block. It is styled with CSS or can be manipulated with JavaScript.
Example:
HTML
<!DOCTYPE html>
<html>
<head>
<style>
.div1 {
background: yellow;
}
.div2 {
background: blue;
}
</style>
</head>
<body>
<div class="div1">
<h1>In Div1</h1>
</div>
<div class="div2">
<h1>In Div2</h1>
</div>
</body>
</html>
Output:
HTML <header>: This tag contains the tagline or we can say it contains the main heading or the navigation links of our web page and is placed at the top of our web page.
Example:
HTML
<!DOCTYPE html>
<html>
<head>
<style>
.div1 {
background: yellow;
}
.div2 {
background: blue;
}
</style>
</head>
<body>
<header>
<h1>This is Heading..</h1>
<p>This is paragraph in the header group</p>
</header>
<div class="div1">
<h1>In Div1</h1>
</div>
<div class="div2">
<h1>In Div2</h1>
</div>
</body>
</html>
Output:
HTML <footer>: This tag contains copyright information, contact information, back-to-top link, and several other related documents and is placed at the bottom of our web page.
Example:
HTML
<!DOCTYPE html>
<html>
<head>
<style>
.div1 {
background: yellow;
}
.div2 {
background: blue;
}
</style>
</head>
<body>
<header>
<h1>This is heading</h1>
<p>This is paragraph in header group</p>
</header>
<div class="div1">
<h1>In Div1</h1>
</div>
<div class="div2">
<h1>In Div2</h1>
</div>
<footer>
<p>This is footer information</p>
<p><a href="mailto:[email protected]">Email</a></p>
</footer>
</body>
</html>
Output:
HTML <section>: This tag is used to define the section in the document.
Example:
HTML
<!DOCTYPE html>
<html>
<head>
<style>
.div1 {
background: yellow;
}
.div2 {
background: blue;
}
#sectionID {
background: grey;
}
</style>
</head>
<body>
<header>
<h1>This is heading</h1>
<p>This is paragraph in header group</p>
</header>
<section id="sectionID">
<b>
<p>This content belongs to section group.</p>
<p>
HTML is a hypertext markup language
which is used to design the web pages
</p>
<p>CSS is used to design the web pages.</p>
<p>
Javascript helps us to manipulate our data
on a webpage.
</p>
<p>Section group ends here..</p>
</b>
</section>
<footer>
<p>This is footer information.</p>
<p><a href="mailto:[email protected]">Email</a></p>
</footer>
</body>
</html>
Output:
Similar Reads
What is HTML DOM ? HTML DOM stands for the Document Object Model is a tree-like structure that offers dynamic interaction and manipulation of the content, structure, and style of an HTML document. It is an interface for web documents. Based on user activity The HTML DOM offers to create interactive web pages where ele
4 min read
What is HTML? HTML (HyperText Markup Language) is the standard markup language used to structure web pages. It is used to create various elements of a webpage/website such as nav-bar, paragraphs, images, video, Forms, and more, which are displayed in a web browser.HTML uses tags to create elements of a webpage.It
3 min read
HTML hgroup Tag The <hgroup> tag in HTML is used to group multiple heading elements (<h1>, <h2>, etc.) together. However, the <hgroup> tag is now deprecated in HTML5 and is no longer recommended for use.HTML<!DOCTYPE html> <html> <body> <hgroup> <h1>This is the
2 min read
What are HTML Tags ? HTML (HyperText Markup Language) is the standard markup language used to create the structure and layout of web pages. HTML documents consist of a series of elements, and these elements are defined using HTML tags. HTML tags are essential building blocks that define the structure and content of a we
2 min read
HTML <colgroup> Tag The <colgroup> tag in HTML is used to group one or more <col> elements, allowing you to apply styles or attributes (such as width) to entire columns in a <table>.HTML<!DOCTYPE html> <html> <body> <table> <colgroup> <col span="2" style="background-co
2 min read