Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App

HTML Course | Building Main Content - Section 2

Last Updated : 05 May, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

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 

building-main-section-2
HTML Course : Building Main Content - Section 2

In 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

main-section2-preview
HTML Course : Building Main Content - Section 2

If 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

main-section2-output1
HTML Course : Building Main Content - Section 2

This 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

main-section2-output-2
HTML Course : Building Main Content - Section 2

It 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.

Step 3: To make the buttons look good, do the following

  • 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

main-section-2-final-output
HTML Course : Building Main Content - Section 2

H

harsh.agarwal0
Improve
Article Tags :
  • HTML
  • CSS-Basics
  • HTML Course Basic

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
    4 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
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences