Understanding Basic HTML: A Beginner's Guide

HTML, or HyperText Markup Language, is the foundation of web development. It provides the structure and layout for web pages, allowing you to create text, images, links, forms, and more. In this beginner's guide, we'll explore the basics of HTML and how it works.

What is HTML?

HTML is a markup language used to create the structure of web pages. It consists of elements, tags, and attributes that define the content and its presentation on a webpage. HTML documents are plain text files with a .html or .htm extension.

Basic Structure of an HTML Document

An HTML document follows a specific structure:

htmlCopy code<!DOCTYPE html>
<html>
<head>
  <title>Title of the Page</title>
</head>
<body>
  <!-- Content goes here -->
</body>
</html>
    1. <html>: This tag represents the root element of an HTML document and encloses all other HTML elements.

      1. <head>: The <head> tag contains meta-information about the document, such as the title, character set, stylesheets, and scripts.

      2. <title>: Inside the <head> section, the <title> tag specifies the title of the web page, which appears in the browser's title bar or tab.

      3. <body>: The <body> tag contains the main content of the web page, including text, images, links, and other elements.

      4. <h1>,<h2>,<h3>, <h4>, <h5>, <h6>: These tags are used to create headings of different levels, with <h1> being the largest and most important heading, and <h6> being the smallest.

      5. <p>: The <p> tag is used to define paragraphs of text.

HTML Elements, Tags, and Attributes

  • Elements: HTML elements are the building blocks of a webpage and are enclosed in opening and closing tags. For example, <p> is an element used for paragraphs.

  • Tags: Tags define the beginning and end of an element. They are enclosed in angle brackets, e.g., <p> and </p> for opening and closing a paragraph.

  • Attributes: Attributes provide additional information about an element and are included within the opening tag. For instance, the href attribute in <a href="https://example.com">Link</a> specifies the URL for a link.

Common HTML Elements

  1. Headings: Used for defining headings of different levels (h1 to h6).

     htmlCopy code<h1>This is a Heading</h1>
     <h2>This is a Subheading</h2>
    
  2. Paragraphs: Used for structuring text content.

     htmlCopy code<p>This is a paragraph.</p>
    
  3. Links: Create clickable links to other web pages.

     htmlCopy code<a href="https://example.com">Click Here</a>
    
  4. Images: Display images on a webpage.

     htmlCopy code<img src="image.jpg" alt="Description of the image">
    
  5. Italic: To make text italics , use the HTML tag <em> or <i>

     <p>This is <em>italicized</em> text <i>using</i> the <em>em</em> tag.</p>
    

Common HTML tag

Common HTML tags are the fundamental building blocks used to structure and format content on a web page. Here are some of the most commonly used HTML tags:

  1. <html>: Defines the root element of an HTML document.

  2. <head>: Contains metadata about the HTML document, such as the title and links to stylesheets.

  3. <title>: Sets the title of the web page displayed in the browser's title bar or tab.

  4. <body>: Contains the main content of the web page, including text, images, links, and other elements.

  5. <h1>, <h2>, <h3>, <h4>, <h5>, <h6>: Heading tags for defining headings of different levels (from largest <h1> to smallest <h6>).

  6. <p>: Defines a paragraph of text.

  7. <a>: Creates hyperlinks to other web pages or resources.

  8. <img>: Inserts an image into the web page.

  9. <div>: Defines a division or section in the document for styling purposes.

  10. <span>: Defines a span of text for applying inline styles or scripting.

  11. <ul>, <ol>, <li>: Used for creating unordered lists (<ul>), ordered lists (<ol>), and list items (<li>).

  12. <table>, <tr>, <th>, <td>: Tags for creating tables and their rows, header cells, and data cells.

  13. <form>, <input>, <button>: Used for creating input forms and form elements like text fields, checkboxes, radio buttons, and buttons.

  14. <br>: Inserts a line break.

  15. <hr>: Creates a horizontal line or separator.

Conclusion

HTML is a fundamental language for web development, allowing you to create structured and meaningful web pages. By understanding the basic structure of HTML documents, HTML elements and tags, attributes, and comments, you can start building your own web pages and learning more advanced web development concepts.

1
Subscribe to my newsletter

Read articles from Chinmaya Mohanty directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Chinmaya Mohanty
Chinmaya Mohanty