HTML Course Basics of HTML

In this article, we will go through all the basic stuff required to write HTML. There are various tags that we must consider and know about while starting to code in HTML. These tags help in the organization and basic formatting of elements in our script or web pages. These step-by-step procedures will guide you through the process of writing HTML.

Table of Content

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

HTML Paragraph

These tags help us to write paragraph statements on a webpage. They start with the <p> tag and end with </p>. Here the <br> tag is used to break the line and acts as a carriage return. <br> is an empty tag. 

Syntax:

<p>w3wiki</p>

Example:  This example shows the use of paragraph tag.

html
<!DOCTYPE html>
<html>

<head>
    <title>Paragraph tag</title>
</head>

<body>
    <h1>Hello w3wiki</h1>
    <p>
        A Computer Science portal for Beginner<br>
        A Computer Science portal for Beginner<br>
        A Computer Science portal for Beginner<br>
    </p>
</body>

</html>

Output

HTML Horizontal Lines

The <hr> tag is used to break the page into various parts, creating horizontal margins with help of a horizontal line running from left to right hand side of the page. This is also an empty tag and doesn’t take any additional statements. 

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 w3wiki</h1>
    <p>
        A Computer Science portal for Beginner<br>
        A Computer Science portal for Beginner<br>
        A Computer Science portal for Beginner<br>
    </p>
    <hr>
    <p>
        A Computer Science portal for Beginner<br>
        A Computer Science portal for Beginner<br>
        A Computer Science portal for Beginner<br>
    </p>
    <hr>
    <p>
        A Computer Science portal for Beginner<br>
        A Computer Science portal for Beginner<br>
        A Computer Science portal for Beginner<br>
    </p>
    <hr>
</body>

</html>

Output

HTML Images

The image tag is used to insert an image into our web page. The source of the image to be inserted is put inside the <img src=”source_of_image“> tag. 

Syntax:

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

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.w3wiki.net/wp-content/cdn-uploads/Geek_logi_-low_res.png">
</body>

</html>

Output

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.

Example: This example illustrates 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.w3wiki.net/" 
       target="_blank" title="Beginner">
       w3wiki
      </a>

    <h2>Image with src, height, and width Attributes:</h2>
    <img src="https://media.w3wiki.net/gfg-gg-logo.svg" 
         alt="w3wiki Image" height="200" 
         width="300">

</body>

</html>

Output:

HTML – Comments

It is used for inserting comments in the HTML 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>w3wiki</p>
</body>

</html>

Output: 

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>w3wiki</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 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>w3wiki</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:

Supported Browser:

  • Google Chrome
  • Microsoft Edge
  • Firefox
  • Opera
  • Safari


Contact Us