1. HTML Basics (25 Questions)
Q1. What is HTML?
HTML stands for HyperText Markup Language. It is the standard language used to create and structure web pages. It tells the browser how to display content like text, images, and links.
Q2. What is the basic structure of an HTML document?
Every HTML document starts with a doctype and has these main parts:
HTML Structure
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<!– Content goes here –>
</body>
</html>
Q3. What is the difference between HTML and HTML5?
HTML is the older version. HTML5 is the latest version that adds new elements (like <video>, <audio>), better semantics, and features like local storage and canvas. It also has a simpler doctype: <!DOCTYPE html>.
Q4. How do you add comments in HTML?
Use <!– comment text –>. Comments are not displayed on the page but help developers understand the code.
Q5. What are HTML tags?
Tags are keywords enclosed in angle brackets < > that define elements. Most tags come in pairs: opening <tag> and closing </tag>.
Example: <p> and </p> for paragraphs.
Q6. What is the difference between a tag and an element?
A tag is just the markup like <p>. An element includes the opening tag, content and closing tag: <p>This is a paragraph.</p>.
Structure:
Tag: <p> (Start Tag), </p> (End Tag).
Element: <p>This is text.</p> (Full Element).
Q7. What are void elements? Give examples.
Void elements do not have closing tags.
Examples: <br>, <img>, <hr>, <input>.
Q8. What is the purpose of the <head> tag?
The <head> contains meta information about the page like title, links to CSS, and character encoding. It does not appear on the visible page.
Q9. What is the purpose of the <body> tag?
The <body> tag contains all the visible content of the web page like text, images, links, and forms.
Q10. How do you create a hyperlink in HTML?
Use the anchor tag: <a href=”https://codexrush.com”>Visit CodeXRush</a>.
Q11. What is the difference between <i> and <em> tags?
The <i> and <em> tags in HTML both style text as italic, but they serve different purposes. The <i> tag is used for visual styling without semantic meaning, while <em> conveys emphasis and adds semantic importance, improving accessibility and meaning in content.
Q12. What is the difference between <strong> and <b> tags?
<strong> has semantic meaning (important text) and is good for accessibility and SEO. <b> is only for visual bold styling without meaning.
Q13. How do you display an image in HTML?
Use <img src=”image.jpg” alt=”Description of image”>.
The alt text is important for accessibility.
Q14. What is the purpose of the alt attribute in images?
It provides alternative text if the image fails to load or for screen readers used by visually impaired users.
Q15. How do you create a line break in HTML?
Use the <br> tag.
Example: First line. <br> Second line.
Q16. What are block-level and inline elements? Give examples.
Block-level elements start on a new line and take full width (e.g., <div>, <p>, <h1>).
Inline elements flow within text (e.g., <span>, <a>, <strong>).
Q17. What is the <title> tag used for?
It sets the title that appears in the browser tab and in search engine results.
Q18. What is the difference between <div> and <span>?
<div> is a block-level container used for grouping sections. <span> is inline and used for styling small parts of text.
Q19. How do you add a horizontal line in HTML?
Use <hr> tag. It creates a thematic break or horizontal rule.
Q20. What is the purpose of the <!DOCTYPE html> declaration?
It tells the browser that the document is HTML5. It must be the first line of the HTML file.
Q21. What happens if you forget the closing tag for a paragraph?
Modern browsers try to fix it automatically, but it can cause unexpected layout issues. Always close tags properly.
Q22. How can you make text bold without using CSS?
Use <strong> or <b> tags. Prefer <strong> for meaning.
Q23. How do you specify the language of a web page?
Add lang=”en” to the <html> tag: <html lang=”en”>.
Q24. What is the difference between physical and logical tags?
Physical tags only change appearance (e.g., <b>, <i>). Logical tags add meaning (e.g., <strong>, <em>).
Q25. Write a simple HTML page that displays “Hello World” with a heading and paragraph.
HTML
<!DOCTYPE html>
<html>
<head><title>Hello</title
</head>
<body>
<h1>Hello World</h1>
<p>Welcome to CodeXRush tutorials.</p>
</body>
</html>




