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.


HTML Basic Quiz

Q1: What does HTML stand for?

A. HyperText Markdown Language
B. HighText Markup Language
C. HyperText Markup Language
D. Home Tool Markup Language

Q2: What is the correct structure for an HTML document?

A. <html><head><title></title></head><body></body></html>
B. <head><body><html></html></body></head>
C. <body><html><head></head></html></body>
D. <html><body><head></head></body></html>

Q3: Which tag is used to define the main content of a webpage?

A. <main>
B. <head>
C. <body>
D. <footer>

Q4: Which HTML element defines the title of the document?

A. <name>
B. <meta>
C. <title>
D. <header>

Q5: Which tag is used for inserting a line break?

A. <break>
B. <lb>
C. <br>
D. <line>

Q6: HTML tags are:

A. Case-sensitive
B. Always uppercase
C. Not case-sensitive
D. Written in italics

Q7: What is the purpose of <!DOCTYPE html>?

A. Declares the version of JavaScript
B. Starts a new HTML line
C. Declares the HTML document type
D. Creates the HTML title

Q8: Which of the following is an empty element?

A. <h1>
B. <p>
C. <body>
D. <br>

Q9: Which element is used to display text in bold?

A. <bold>
B. <b>
C. <strong>
D. Both b and c

Q10: Where should the <title> tag be placed?

A. Inside the <body>
B. After the <html> tag
C. Inside the <head>
D. At the end of the document

Go Back Top