HTML Course | Building Main Content - Section 2
Last Updated :
05 May, 2025
In this article, we will build a three-column layout where each column describes a course and includes a "Learn More" button. Using CSS, we’ll arrange the columns side-by-side and will style them accordingly.
Course Navigation
HTML Course : Building Main Content - Section 2In the last chapter, we began building the main section of the website and have completed the first section. Let us now move to the section 2 of Main Content. You can see the Section 2 of the Main Content in the below image
HTML Course : Building Main Content - Section 2If you observe carefully, you can say that the section 2 is divided into three columns. This is also referred to as 3-Column layout in terminology of Web Development.
Steps To Building Setction 2 of Main Content
Step 1: Let's start writing HTML for Section 2
- Declare a parent div with a class named row.
- Declare three div's inside the parent row div to contain three columns and assign them id's as column1, column2 and column3 respectively.
- For Each Column:
- Declare a div with class = "column-title". For the title of the column.
- Declare a paragraph p element for the description of the content.
- Declare an anchor tag <a> to add an external link which will be styled as a button later.
Below is the complete HTML code for the Section 2 of the Main Content
HTML
<!DOCTYPE html>
<html>
<body>
<!-- Section 2 of Main content -->
<section class="container" id="section-2">
<div class="row">
<div id="column1">
<div class="column-title">
<h2>GFG Content</h2>
</div>
<p>
A Computer Science portal for geeks. It
contains well written, well thought and
well explained computer science and
programming articles, quizzes and ...
</p>
<a href=
"https://www.geeksforgeeks.org"
target="_blank"
class="button">
Learn More
</a>
</div>
<div id="column2">
<div class="column-title">
<h2>GFG Practice</h2>
</div>
<p>
A practice poratal to test your knowledge
of data structures and algorithms by solving
problems asked in interviews of many tech giants
like, Amazon, Microsoft etc.
</p>
<a href=
"https://practice.geeksforgeeks.org"
target="_blank"
class="button">
Learn More
</a>
</div>
<div id="column3">
<div class="column-title">
<h2>GFG IDE</h2>
</div>
<p>
An integrated development environment to
run and test your codes in almost all of
the popular and widely used programming
languages.
</p>
<a href=
"https://www.geeksforgeeks.org/community/"
target="_blank" class="button">
Learn More
</a>
</div>
</div>
</section>
</body>
</html>
Output: Run the index.html in your browser, you will be able to see something as shown below
HTML Course : Building Main Content - Section 2This no where looks close to our final Section 2 in the Main Content. We need to add some styles to make it beautiul.
Step 2: Let's start adding styles to it.
- Adding basic styles for layout: Firstly, set the overflow to hidden and add all the required margins and paddings. Next is to give the thin 1px border at the top of the section to separate it from the previous section and align all of the text inside it to center.
CSS
/*Add the below CSS code to your style.css*/
#section-2{
overflow: hidden;
margin-top: 5em;
padding-top: 1em;
border-top: 1px solid rgba(0, 0, 0, 0.2);
text-align: center;
}
- Aligning Columns In-line: The next step is to align all of the columns in a single line one after the other. To do this, add the below CSS code to your style.css file:
CSS
/*Add the below CSS code to your style.css*/
.row #column1,
.row #column2,
.row #column3{
float: left;
width: 320px;
padding: 80px 40px 80px 40px;
}
- Styling the Title of columns: The next good thing to do is to style the title of the columns. To give them appropriate font-sizes and weights apart from the default values. Add the below CSS code to your style.css file:
CSS
/*Add the below CSS code to your style.css*/
.column-title h2{
margin: 1em 0em;
font-size: 1.6em;
font-weight: 700;
}
Once you have added the above styles successfully, your Section 2 now will look something as shown below
HTML Course : Building Main Content - Section 2It looks good now apart from the buttons at the bottom. The buttons are still appearing as simple links. Let's make them look good by adding some CSS.
- Remove text-decoration.
- Align text to center.
- Set the display property to "inline-block".
- Set appropriate font-size, color and background color of the button.
- Add paddings and margins.
- Set the cursor property to pointer so that whenever the user hovers over the button the mouse pointer will change into a nice looking hand representing a pointer.
- Use the :hover selector to add styles whenever user hovers over the button.
Below is the complete CSS code for the "button" class which you need to add in your style.css file
CSS
.button {
text-decoration: none;
text-align: center;
display: inline-block;
font-size: 16px;
background-color: #4CAF50;
color: white;
border: 2px solid #4CAF50;
padding: 16px 32px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
cursor: pointer;
}
.button:hover {
background-color: white;
color: #4CAF50;
}
Now, the Section 2 of our website is complete and will look something as shown below
HTML Course : Building Main Content - Section 2
Similar Reads
Introduction to HTML and CSS | Learn to Design Your First Website in Just 1 Week Ready to Design Your First Website in Just 1 Week? With this guide, learn how to build a simple yet stylish website in just one week to gain skills and confidence.This is an introduction course to HTML and CSS which will help you learn all about the basics of HTML and CSS needed to begin with Web De
4 min read
HTML Course | Structure of an HTML Document HTML (Hypertext Markup Language) is used in over 95% of websites and is the foundation of all web pages. It provides the basic structure and content layout. For beginners in web development, learning HTML is the essential first step. Structure of an HTML DocumentWhat is an HTML Document?HTML is a ma
4 min read
HTML Course | First Web Page Printing Hello World So far, we have already learned about the structure of an HTML document, tags, etc in the previous module. Let us use this knowledge to create our first web page.Here, we are creating a simple webpage that displays a "Hello World" message as the perfect starting point. This exercise will help you un
2 min read
HTML Course | Basics of HTML Now that you've created your first "Hello World" webpage, it's time to learn some important concepts of HTML. In this chapter, weâll cover basic elements that add content and structure, including paragraphs, images, lists, attributes, comments, and more. Table of ContentHTML Paragraph HTML Horizonta
6 min read
HTML Course | Starting the Project - Creating Directories Now we have understood the important concepts of HTML, it's time to start building a structured web project. In this chapter, youâll learn how to set up directories and organize files efficiently. It is important to have a well-structured directory for both small and large projects, as it makes your
3 min read
HTML Course | Understanding and Building Project Structure Now that you've already set up a basic directory structure, it's time to understand and build the basic structure of our project.Course Navigation Understanding and Building Project StructureWe have already created all of the directories needed for our project. Let's just start writing our HTML code
3 min read
CSS Introduction CSS (Cascading Style Sheets) is a language designed to simplify the process of making web pages presentable.It allows you to apply styles to HTML documents by prescribing colors, fonts, spacing, and positioning.The main advantages are the separation of content (in HTML) and styling (in CSS) and the
5 min read
HTML Course | Creating Navigation Menu A navigation menu is the first element we see in any website. It allows users to explore different pages and sections easily. In this chapter, youâll learn how to create a navigation menu in HTML.Course Navigation HTML Course : Creating Navigation MenuIn the last chapter, we have created the entire
6 min read
HTML Course | Building Header of the Website The header is the top part of the website and the important area for branding and navigation. In this chapter, youâll learn how to build a header with the tags which we have already learnt.Course Navigation HTML Course : Building Header of the WebsiteSo far, we have created the navigation bar for th
4 min read
HTML Course | Building Main Content - Section 1 The main content of a website is where you show the core information that visitors are looking for. This could be text, images, links, or any important details about your services, products, or ideas.Course Navigation HTML Course : Building Main Content - Section 1We just completed building the head
4 min read