Q: What are self-closing tags in HTML?
A: Tags that do not have a separate closing tag, used for elements without content.
Examples: img, br, hr, input, metaQ: Difference between HTML Tags and HTML Elements
A:
-
Tag: Code in < >, e.g.,
or
-
Element: Complete structure with start tag, content, and end tag, e.g.,
Hello
- Q: Difference between id and class attributes A:
- id: Unique, identifies one element, e.g.,
- class: Can be used for many elements, e.g.,
- Q: Difference between , , A:
- – Thematic section, e.g.,
About
- – Standalone content, e.g.,
Blog
- – Sidebar/related content, e.g.,
Links
- Q: Purpose of tag A: Provides metadata about the page, placed in . Examples:
<meta charset="UTF-8">, <meta name="viewport" content="width=device-width, initial-scale=1.0">
- Q: Explain this HTML code:
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body></body>
</html>
A:
- !DOCTYPE html – HTML5 declaration
- html lang="en" – Root element with language English
- head– Metadata section
- meta charset="UTF-8" – Character encoding
- meta name="viewport" – Mobile responsive
- title – Browser tab title
- body – Visible content section
-
Q: Difference between ,
,
A:
Tag | Location | Purpose | Visible on Page? |
---|---|---|---|
<title> |
Inside <head>
|
Sets the page title (shown in browser tab & search engines) | ❌ No |
<h1> |
Inside <body>
|
Defines the main heading of the webpage | ✅ Yes |
<header> |
Inside <body>
|
Groups header content (logo, nav, h1, etc.) | ✅ Yes |
Top comments (0)