VOOZH about

URL: https://www.geeksforgeeks.org/html/html-course-basics-of-html/

⇱ HTML Course | Basics of HTML - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML Course | Basics of HTML

Last Updated : 11 Jul, 2025

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.

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.

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.

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.

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.

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.

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.

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.

Output


πŸ‘ html-tables
HTML Course: Basics of HTML
Comment