-
Hajipur, Bihar, 844101
HTML and XHTML are both markup languages used to create web pages. However, they differ in syntax rules, strictness, and compatibility with XML.
HTML (HyperText Markup Language) is the standard language for creating web pages. It is lenient and allows certain syntax flexibility, such as unclosed tags or lowercase/uppercase tag names.
XHTML (eXtensible HyperText Markup Language) is a stricter and well-formed version of HTML that follows XML rules. It was designed to improve HTML’s structure and enable better compatibility with XML-based tools.
Feature | HTML | XHTML |
---|---|---|
Based on | SGML | XML |
Tag Names | Not case-sensitive | Must be lowercase |
Closing Tags | Optional for some tags | Required for all tags |
Attribute Quotation | Optional | Required |
Attribute Minimization | Allowed (checked ) |
Not allowed (checked="checked" ) |
Doctype Declaration | Optional | Required |
Error Handling | Browser tries to fix it | Strict – page may not render |
Compatibility | More forgiving | Requires XML parsers |
<!DOCTYPE html>
<html>
<head>
<title>HTML Page</title>
</head>
<body>
<h1>Welcome</h1>
<input type="checkbox" checked>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XHTML Page</title>
</head>
<body>
<h1>Welcome</h1>
<input type="checkbox" checked="checked" />
</body>
</html>
Q1. Write a simple HTML document using lenient syntax.
Q2. Convert an HTML document into valid XHTML format.
Q3. Demonstrate the use of self-closing tags in XHTML.
Q4. Show how attribute values differ in HTML and XHTML.
Q5. Explain why XHTML requires case sensitivity.
Q6. Write a form in XHTML with properly quoted attributes.
Q7. Validate an XHTML file using a W3C validator.
Q8. Identify and correct syntax errors in a mixed HTML/XHTML page.
Q9. Compare error handling in HTML vs. XHTML.
Q10. Explain why XHTML is more compatible with XML tools.
Q1: What is XHTML based on?
Q2: In XHTML, all tags must be:
Q3: How must attributes be written in XHTML?
Q4: Which of the following is a valid XHTML self-closing tag?
Q5: What does HTML do when it encounters an error?
Q6: Which document type declaration is used in XHTML 1.0 Strict?
Q7: In XHTML, how should a checkbox be marked as checked?
Q8: XHTML pages require:
Q9: XHTML is more ___ than HTML.