image

Basics Of Html

HTML (HyperText Markup Language) is the foundation of every website. It defines the structure and content of web pages, allowing browsers to display text, images, links, and multimedia in an organized way. Without HTML, web pages wouldn’t exist.



1.Html tags that comes in pairs

Most HTML tags come in pairs — an opening tag and a closing tag. The opening tag tells the browser where an element begins, and the closing tag (which includes a forward slash “/”) tells where it ends. For example:

This is a paragraph.

These paired tags help structure web content properly, ensuring that text, images, and other elements are displayed correctly on a webpage.



2.Basic Html structure

Every HTML document follows a simple structure that tells the browser how to display a web page.

It begins with !DOCTYPE html to declare that the document is HTML5. The html tag wraps the entire content. Inside it, there are two main parts:

head — contains information about the page, such as the title, links to CSS files, and meta data.

body — contains all the visible content like text, images, buttons, and links.

Example

Example of HTML structure:

<!DOCTYPE html>
<html>
  <head>
    <title>My First Page</title>
  </head>
  <body>
    <h1>Hello World!</h1>
  </body>
</html>

3.Understanding the <input> Tag

The <input> tag in HTML is used to create interactive fields where users can enter data, such as text, email, passwords, or numbers. It is one of the most commonly used form elements.

Below is an example of a simple input field where a user can type their name:


You can also change the type attribute of the <input> tag to create different kinds of inputs — for example:

  • <input type="email"> → for email addresses
  • <input type="password"> → for passwords
  • <input type="number"> → for numbers

4.Understanding the <select> Tag

The <select> tag creates a drop-down list that allows users to pick from several options. Each choice inside the list is wrapped in an <option> tag.

Example: Choose your favorite programming language below 👇


You can use the name attribute to identify the select box in a form, and add the multiple attribute if you want users to select more than one option.

5.Understanding the <button> Tag

The <button> tag is used to create clickable buttons on a webpage. Buttons make websites interactive and are often used to submit forms or trigger JavaScript functions.

Here are some common examples:

You can also use the onclick attribute to make a button perform actions using JavaScript. For example:

<button onclick="alert('Hello, world!')">Click Me</button>
  

6.Using the <img> Tag

The <img> tag lets you add pictures to your website. You can use images from your own files or from the internet.

Here’s an example of how to add an image:

<img src="images/html-logo.png" alt="HTML Logo" width="200" height="200">
  

Example result 👇

HTML5 Logo

💡 Tip: Always include the alt attribute so users with slow connections or screen readers can understand what the image represents.

7.Using the <a> Tag (Links)

The <a> tag is used to add links to your webpage. You can use it to connect pages, download files, or link to external websites.

Example:

<a href="https://www.learn2code.com" target="_blank" title="Visit Learn2Code Website">
  Visit Learn2Code
</a>
  

Example result 👇

Visit Learn2Code

💡 Tip: Use target="_blank" carefully — it opens links in a new browser tab. Always use meaningful link text so users know where they are going.

8.Using <header> and <footer> Tags

The <header> and <footer> tags define the top and bottom sections of a webpage. They help structure your page and make your code easier to read and maintain.

Here’s a simple example 👇

<header>
  <h1>Welcome to Learn2Code</h1>
  <nav>
    <a href="#home">Home</a> |
    <a href="#courses">Courses</a> |
    <a href="#contact">Contact</a>
  </nav>
</header>

<main>
  <p>This is the main content of the page.</p>
</main>

<footer>
  <p>© 2025 Learn2Code. All rights reserved.</p>
</footer>
  

Example result 👇

Welcome to Learn2Code

This is the main content of the page.

© 2025 Learn2Code. All rights reserved.

💡 Tip: Every page can have its own header and footer. They help create a consistent layout across your entire website.

9.Understanding the id Attribute

The id attribute gives an element a unique name, allowing you to target it with CSS or JavaScript. No two elements on a page should have the same ID.

Example:

<h2 id="intro">Welcome to Learn2Code</h2>
<p>Learn the basics of HTML, CSS, and JavaScript.</p>

<style>
  #intro {
    color: blue;
    text-align: center;
  }
</style>
  

Example result 👇

Welcome to Learn2Code

Learn the basics of HTML, CSS, and JavaScript.

💡 Tip: Use id when you want to target a single element. For styling multiple elements, use a class instead.

10.Understanding the <li> Tag

The <li> tag defines a single list item. It is used inside <ul> (unordered lists) or <ol> (ordered lists).

Example of an Unordered List:

<ul>
  <li>HTML</li>
  <li>CSS</li>
  <li>JavaScript</li>
</ul>
  

Example result 👇

  • HTML
  • CSS
  • JavaScript

Example of an Ordered List:

<ol>
  <li>Learn HTML</li>
  <li>Learn CSS</li>
  <li>Learn JavaScript</li>
</ol>
  

Example result 👇

  1. Learn HTML
  2. Learn CSS
  3. Learn JavaScript

💡 Tip: Use <ul> for unordered lists and <ol> for ordered lists. Each list item must always be inside an <li> tag.

11.Understanding the <ul> Tag

The <ul> tag defines an unordered list. It displays a list of items with bullet points. Each item is written inside an <li> tag.

Example:

<ul>
  <li>HTML</li>
  <li>CSS</li>
  <li>JavaScript</li>
</ul>
  

Example result 👇

    • HTML
    • CSS
    • JavaScript

    💡 Tip: You can change the bullet style using CSS — for example:

    ul {
      list-style-type: square;
    }
      

    Other list styles include circle, disc, or none.

    11.Understanding the <ol> Tag

    The <ol> tag is used to make an ordered (numbered) list. Each item inside must be wrapped in an <li> tag.

    Example:

    <ol>
      <li>Learn HTML</li>
      <li>Learn CSS</li>
      <li>Learn JavaScript</li>
    </ol>
      

    Example result 👇

    1. Learn HTML
    2. Learn CSS
    3. Learn JavaScript

    Using the type Attribute:

    <ol type="A">
      <li>First</li>
      <li>Second</li>
    </ol>
      

    💡 type options include:

    • 1 → Numbers (default)
    • A → Uppercase letters
    • a → Lowercase letters
    • I → Roman numerals (uppercase)
    • i → Roman numerals (lowercase)

    12.HTML <p> Tag (Paragraph)

    The <p> tag in HTML is used to define a paragraph of text. It helps to separate content into readable sections. Browsers automatically add some space before and after each paragraph to make the text look neat.

    Example:


    13.HTML <head> Tag

    The <head> tag is used to contain important information about a webpage that is not shown directly on the page itself. It includes details such as the page title, links to stylesheets, scripts, and meta information (like description and keywords).

    Example:




    14.HTML <body> Tag

    The <body> tag is used to define the main visible content of a webpage. Everything that appears on your screen — such as text, images, buttons, videos, and links — is placed inside the <body> tag.

    In simple terms, the <head> is for information about the page, while the <body> is for what users actually see.

    Example:


    . recommend video


    🌐 HTML Basics Quiz

    1. What does HTML stand for?



    2. Which tag is used to display the largest heading?



    3. What is the correct tag for inserting an image?



    4. Which attribute is used to provide a link in the <a> tag?



    5. What tag is used to create a line break?