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
Next Article:
HTML Course | Starting the Project - Creating Directories
Next article icon

HTML Course | Basics of HTML

Last Updated : 24 Nov, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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 Content

  • HTML Paragraph 
  • HTML Horizontal Lines 
  • HTML Images 
  • HTML - Attributes 
  • HTML - Comments
  • HTML - Lists 
  • HTML Tables

HTML Paragraph 

The <p> tag is used to create paragraphs, which helps to structure and organize text content. Each <p> tag creates a new paragraph and ends with </p>.

Here the <br> tag is used to break the line and it is an empty tag means it doesn't require a closing tag.

Syntax

<p>GeeksforGeeks</p>

Example: This example shows the use of paragraph tag.

html
<!DOCTYPE html> <html>  <head>     <title>Paragraph tag</title> </head>  <body>     <h1>Hello GeeksforGeeks</h1>     <p>         A Computer Science portal for geeks<br>         A Computer Science portal for geeks<br>         A Computer Science portal for geeks<br>     </p> </body>  </html> 

Output

html-paragraph-tag
Basics of HTML

HTML Horizontal Lines 

The <hr> tag creates a horizontal line across the page, often used to separate sections of content. This tag is self-closing and doesn’t require a closing </hr> tag.

Syntax

<hr>

Example: This example shows the use of horizontal row tag in an HTML document.

html
<!DOCTYPE html> <html>  <head>     <title>Horizontal row</title> </head>  <body>     <h1>Hello GeeksforGeeks</h1>     <p>         A Computer Science portal for geeks<br>         A Computer Science portal for geeks<br>         A Computer Science portal for geeks<br>     </p>     <hr>     <p>         A Computer Science portal for geeks<br>         A Computer Science portal for geeks<br>         A Computer Science portal for geeks<br>     </p>     <hr>     <p>         A Computer Science portal for geeks<br>         A Computer Science portal for geeks<br>         A Computer Science portal for geeks<br>     </p>     <hr> </body>  </html> 

Output

html-horizontal-line
Basics of HTML

HTML Images 

The image tag is used to insert an image into our web page. It requires the src attribute for the image path and the alt attribute for alternative text (useful for accessibility and SEO). 

Syntax

<img src="geeks.png" alt="image">

Attributes in Images

  • src: Specifies the URL or path of the image file.
  • alt: Provides a text description of the image, shown if the image cannot be displayed.
  • width and height: Control the dimensions of the image.
<img src="geeks.png" alt="image" width="500" height="300">

Example: This example shows the use of HTML images in an HTML document.

html
<!DOCTYPE html> <html>  <head>     <title>HTML Images</title> </head>  <body>     <img src=        "https://media.geeksforgeeks.org/wp-content/cdn-uploads/Geek_logi_-low_res.png"> </body>  </html> 

Output

html-images
HTML Course: Basics of HTML

HTML - Attributes 

An attribute is used to provide extra or additional information about an element. It takes two parameters name and value.

The name parameter takes the name of the property we would like to assign to the element and the value takes the properties value or extent of the property names that can be aligned over the element. Every name has some value that must be written within quotes. (e.g., class="example").

Common Attributes

  • id: Uniquely identifies an element.
  • class: Assigns a CSS class to the element for styling.
  • style: Allows inline styling (e.g., style="color:red;")
<p id="intro" class="text-large" style="color: blue;">This is a paragraph with an ID, class, and inline style.</p>

Example: This example shows the use of href, height,width and src attribute in an HTML document.

HTML
<!DOCTYPE html> <html lang="en">  <head>     <meta charset="UTF-8">     <meta name="viewport"            content="width=device-width, initial-scale=1.0">     <title>HTML Attributes</title> </head>  <body>      <h2>Link with href Attribute</h2>     <a href="https://www.geeksforgeeks.org/"         target="_blank" title="Geeks">        GeeksforGeeks       </a>      <h2>Image with src, height, and width Attributes:</h2>     <img src="https://media.geeksforgeeks.org/gfg-gg-logo.svg"           alt="GeeksforGeeks Image" height="200"           width="300">  </body>  </html> 

Output


html-attributes
HTML Course: Basics of HTML


HTML - Comments

Comments are not displayed on the webpage; they're used to explain the code. Comments are helpful for documentation or temporarily disabling code.

Using comments, specially in complex code, is the best practice of coding so that coder and reader can get help for understanding. It gives help to coder / reader of code to identify pieces of code specially in complex source code.

Syntax

<!-- Write your comments here -->

Example:  This example shows the use of HTML comments in an HTML document.

HTML
<!DOCTYPE html> <html lang="en">  <head>     <meta charset="UTF-8">     <meta name="viewport"            content="width=device-width, initial-scale=1.0">     <title>comment in HTML</title> </head>  <body>     <!-- there is a comment -->     <p>GeeksforGeeks</p> </body>  </html> 

Output


html-comments
HTML Course: Basics of HTML


HTML - Lists 

A list is a record of short pieces of information, such as people's names, usually written or printed with a single thing on each line and ordered in a way that makes a particular thing easy to find. For example shopping list , To-do list etc. HTML offers three ways for specifying lists of information. All lists must contain one or more list 

  • unordered list (ul) : This will list items using plain bullets.
  • ordered list (ol) : This will use different schemes of numbers to list your items.
  • definition list (dl) : This arranges your items in the same way as they are arranged in a dictionary.

Example: This example illustrates the use of HTML list with help of HTML document.

HTML
<!DOCTYPE html> <html lang="en">  <head>     <meta charset="UTF-8">     <meta name="viewport"            content="width=device-width, initial-scale=1.0">     <title>HTML list</title>     <style>         h1 {             color: green;         }     </style> </head>  <body>     <h1>GeeksforGeeks</h1>     <h3>HTML Lists</h3>     <h2>Ordered List:</h2>     <ol>         <li>DSA</li>         <li>MERN</li>         <li>MEAN</li>     </ol>      <h2>Unordered List:</h2>     <ul>         <li>DSA</li>         <li>MERN</li>         <li>MEAN</li>     </ul>  </body>  </html> 

Output


html-lists
HTML Course: Basics of HTML


HTML Tables

HTML table is a structured way to display data in rows and columns on a web page. It consists of a series of elements that define the structure of the table and its contents.

  • <table>: The main container element for the table. It contains all the rows and columns of the table.
  • <tr>: Defines a single row in the table. It contains one or more <td> or <th> elements.
  • <td>: Defines a cell in a table row. It contains the actual data of the table.
  • <th>: Defines a header cell in a table. It is typically used to represent column or row headers and is usually bold and centered by default.

Example: Below example shows how we can create a table in HTML.

HTML
<!DOCTYPE html> <html> <head>     <style>       body{         text-align: center;       }       h1{         color: green;       }         table {             border-collapse: collapse;             width: 100%;         }         th, td {             border: 1px solid black;             padding: 8px;             text-align: left;         }         th {             background-color: #f2f2f2;         }     </style> </head> <body>   <h1>GeeksForGeeks</h1>   <h3>HTML Tables</h3>  <table>     <thead>         <tr>             <th>Name</th>             <th>Roll No</th>             <th>Div</th>         </tr>     </thead>     <tbody>         <tr>             <td>Prasad Bade</td>             <td>23</td>             <td>D</td>         </tr>         <tr>             <td>Saurabh Puri</td>             <td>87</td>             <td>A</td>         </tr>     </tbody> </table>  </body> </html> 

Output


html-tables
HTML Course: Basics of HTML

Next Article
HTML Course | Starting the Project - Creating Directories

H

harsh.agarwal0
Improve
Article Tags :
  • Misc
  • Web Technologies
  • HTML
  • HTML Course Basic
Practice Tags :
  • Misc

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