HTML Basic


🔹 What is HTML?

HTML stands for HyperText Markup Language. It is the standard language used to create web pages. HTML describes the structure of a webpage using elements (also called tags).


🔹 Basic Structure of an HTML Document

Every HTML document has a basic structure. Here's a complete example:

<!DOCTYPE html>
<html>
<head>
  <title>My First HTML Page</title>
</head>
<body>
  <h1>Hello, World!</h1>
  <p>This is my first paragraph in HTML.</p>
</body>
</html>

📌 Explanation:
Tag Purpose
<!DOCTYPE html> Declares the document type and HTML version
<html> Root element of the HTML document
<head> Contains metadata (like <title>)
<title> Title of the webpage (appears in browser tab)
<body> Visible content on the page
<h1> to <h6> Headings (from largest to smallest)
<p> Paragraph of text

🔹 HTML Tags are Not Case-Sensitive

This means <HTML> and <html> are treated the same. However, it’s best to use lowercase as per modern HTML standards.


🔹 Nesting HTML Elements

HTML elements can be nested (placed inside one another):

<body>
  <h2>My Website</h2>
  <p>This is a <strong>bold</strong> word inside a paragraph.</p>
</body>

🔹 Empty Elements

Some elements don’t have closing tags. These are called empty elements. Example:

<br>  <!-- Line break -->
<hr>  <!-- Horizontal rule -->

🔹 Writing HTML in a Real Editor

Use editors like:

  • Notepad / Notepad++ (Windows)

  • VS Code (Cross-platform)

Save the file with a .html extension and open it in any browser.


Practice Questions

Q1. Write a complete HTML document that displays a heading and a paragraph.

Q2. Add the <title> tag to show "My Website" in the browser tab.

Q3. Use an <h1> tag to display "Welcome!" on the webpage.

Q4. Create a paragraph using the <p> tag with any text.

Q5. Add a horizontal line between two paragraphs using <hr>.

Q6. Insert a line break in a sentence using the <br> tag.

Q7. Write a nested element: a paragraph with bold text inside it using <strong>.

Q8. Save your file as basic.html and open it in a browser.

Q9. Create headings from <h1> to <h6> in one HTML page.

Q10. Create an HTML file with two paragraphs and one line break in each.


Go Back Top