HTML

What is HTML?

Answer:

HTML is the language that helps create and organize the content of a website. You can think of it as the framework of a house—it decides where headings, paragraphs, images, and links should go so that everything looks orderly. Without HTML, a webpage would just be plain text on a screen, with no clear layout or structure.

Example:

<!DOCTYPE html>
<html>
<head>
  <title>Welcome to Ravi Web</title>
</head>
<body>
  <h1>Hello World!</h1>
  <p>This is a simple demonstration of a web page using HTML.</p>
  <a href="https://raviwebcodes.com" target="_blank">Check Example</a>
</body>
</html>
Difference between HTML and XHTML

Answer:

  • HTML (HyperText Markup Language):
    HTML is more flexible. Even if you forget to close a tag or make small mistakes, most web browsers will still display the page correctly.
  • XHTML (Extensible HyperText Markup Language):
    XHTML follows very strict rules because it is based on XML. Every tag must be properly opened and closed. If you miss anything, the page might not work properly.

Example (XHTML style):

<img src="logo.png" alt="Ravi Web Logo" />
Why is HTML5 important?

Answer:

HTML5 is a major upgrade of HTML that makes web development smarter and more powerful. It is important because:

  1. Semantic tags – It introduced tags like <header><article><footer>, which give clear meaning to the structure of a webpage. This improves readability and SEO.
  2. Built-in multimedia support – You don’t need extra plugins for audio or video. With <audio> and <video>, media can run directly in the browser.
  3. Local storage – HTML5 gives features like localStorage and sessionStorage, which allow data to be saved on the user’s browser itself (without needing cookies).
  4. APIs and advanced features – It provides APIs for graphics, geolocation, offline applications, and responsive design, making modern websites more interactive.

Example (using HTML5 features)

<!DOCTYPE html>
<html>
<head>
  <title>HTML5 Example</title>
</head>
<body>
  <header>
    <h1>Welcome to My Website Ravi Web</h1>
  </header>

  <article>
    <p>This is an article section with semantic structure.</p>
  </article>

  <video controls width="300">
    <source src="video.mp4" type="video/mp4">
    Your browser does not support the video tag.
  </video>
</body>
</html>
What is the purpose of Doctype?

Answer:

The Doctype declaration is placed at the very top of an HTML document. Its main role is to tell the browser which version of HTML is being used in the page. This helps the browser to display the web page in a standard and consistent way.

If the Doctype is missing or incorrect, the browser may use quirks mode, which can make the page look different or cause design issues.

Example Doctype:

<!DOCTYPE html>

What is Semantic HTML?

Answer:

Semantic HTML uses meaningful tags (like <header><nav><section><article><footer>) that describe the role of the content, making web pages more structured, accessible, and SEO-friendly.

Example:

<header>Ravi Web Header</header>
<main>Website Content</main>
<footer>© 2025 Ravi Web</footer>
How do you write comments in HTML?

Answer:

HTML comments are written between the markers <!– and –>, and they are not shown by browsers on the page, only in the source code for developers to read.

<!-- This is a comment for developers -->
What is the difference between block-level and inline elements?

Answer:

  • Block-level elements always start on a new line and span the full width of their container (e.g., <div><p>).
  • Inline elements stay within the flow of text, occupying only the space their content needs (e.g., <span><a>).
<p>This is a block element</p>
<span>This is an inline element</span>
How many heading tags are there in HTML?

Answer:
HTML has six heading tags: <h1> to <h6>.

Example:

<h1>Ravi Web Heading 1</h1>
<h2>Ravi Web Heading 2</h2>
<h3>Ravi Web Heading 3</h3>
<h4>Ravi Web Heading 4</h4>
<h5>Ravi Web Heading 5</h5>
<h6>Ravi Web Heading 6</h6>
What are HTML Entities?

Answer:

Sometimes we need to display symbols that cannot be typed directly from the keyboard. In such cases, HTML entities are used. With their help, we can easily show special characters like © (copyright) and ® (registered) on a web page.

Example:

<p>Copyright &copy; 2025 Ravi Web</p>
<p>Less than symbol: &lt;</p>

How to create hyperlinks in HTML?

Answer:

In HTML, you can make any text clickable by wrapping it with an <a> tag. The href part inside this tag tells the browser which page or website should open when the link is clicked.

Example:

<a href="https://raviwebcodes.com">Visit Ravi Web</a>