HTML - Layouts
HTML - Layouts
HTML - Layouts
HTML Layouts specifies the arrangement of components on an HTML web page. A good
layout structure of the webpage is important to provide a user-friendly experience on our
website. It takes considerable time to design a website's layout with a great look and
feel.
Elements Description
The header tag is used to add a header section in an HTML web page. All
header
the content inside this tag will be on top of the webpage.
It defines a major part of the web page where all the important content
section
will be displayed.
footer The footer tag defines the footer section of the webpage. This section
contains copyright information and other important details. It will always
Page 2 of 5
Visit this chapter to learn about the various elements with examples that are used for
creating HTML layouts: HTML Layout Elements
Open Compiler
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.header {
background-color: #b3e0f2;
text-align: center;
padding: 20px;
font-size: 2em;
font-weight: bold;
}
.container {
display: flex;
}
.sidebar {
Page 3 of 5
width: 20%;
background-color: #f4f4f4;
padding: 20px;
}
.content {
width: 80%;
background-color: #f9f9f9;
padding: 20px;
}
.footer {
background-color: #b3e0f2;
text-align: center;
padding: 10px;
position: fixed;
width: 100%;
bottom: 0;
}
</style>
</head>
<body>
<div class="header">
Title
</div>
<div class="container">
<div class="sidebar">
<a href="#">Home</a>
<a href="#">Learn HTML</a>
<a href="#">About Us</a>
</div>
<div class="content">
<h1>Home</h1>
<p>This is a home page.</p>
</div>
</div>
<div class="footer">
Footer
</div>
</body>
</html>
The CSS Bootstrap library can be used to make layouts in HTML. The following code
shows how it's done:
Open Compiler
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Bootstrap CDN Link -->
<link href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<!-- Header -->
<header class="bg-info text-white text-center py-4">
<h1>Title</h1>
</header>
</ul>
</div>
</nav>
Explore our latest online courses and learn new skills at your own pace. Enroll and
become a certified expert to boost your career.
CSS Flexbox Property: Used for dynamic layout and to position elements in
different screen sizes.
CSS frameworks: The framework, like Bootstrap, allows to create dynamic HTML
layouts.
To learn how to use CSS for making HTML layouts, visit the chapter Layouts Using CSS