HTML Questions & Answers – The Rules of (X)HTML

This set of HTML Interview Questions and Answers focuses on “The Rules of (X)HTML”.

1. Which of the following prints bold letters in traditional HTML?

i. <B>Go boldly</B>
ii. <B>Go boldly</b>
iii. <b>Go boldly</B>
iv. <b>Go boldly</b>

a) iv
b) i
c) i, ii, iii, and iv
d) both iv and i
View Answer

Answer: c
Explanation: Traditional HTML is case insensitive and thus we can write tag/element name either in lowercase or uppercase or both which will be ignored by browser by default.
advertisement
advertisement

2. XHTML is case insensitive and HTML is case sensitive.
a) True
b) False
View Answer

Answer: b
Explanation: Traditionally XHTML is case sensitive while HTML is case insensitive. In HTML these are ignored by default by browsers.

3. What output do you expect if the following markup is rendered?

<strong>T   e    s   t   o  f  s  p  a  c  e  s</strong><br>
<strong>T e s t &nbsp;o f&nbsp; s p a c e s </strong><br>

a) T e s t o f s p a c e s
T e s t o f s p a c e s
b) Testofspaces
Testofspaces
c) T e s t o f s p a c e s
T e s t  o f  s p a c e s
d) T e s t o f s p a c e s T e s t o f s p a c e s
View Answer

Answer: c
Explanation: The strong tag is used to highlight the importance of text/paragraph. <br> tag is used for a line break in HTML. Ant white space between characters displays as a single space.
advertisement

4. Which of the following options follows content model in HTML?

i.<ul>
     <p>Option one </p>
  </ul>
ii.<ul>
     <li>Option two </li>
  </ul>

a) i
b) ii
c) i and ii
d) Neither i nor ii
View Answer

Answer: b
Explanation: Content model specifies that certain elements are supposed to occur only within other elements. The <ul> tag which is for unordered list should contain <li> tags which are for list specification. The <p> tag is used for paragraph in HTML.
advertisement

5. Which of the following is not an empty element?

a) <hr/>
b) <br/>
c) <p/>
d) Both <hr/> and <br/>
View Answer
Answer: c
Explanation: An element is said to be empty if it doesn’t contain any content in it. The <hr/> and <br/> tag which is used for a horizontal line and line break respectively, doen’t contains any content in it and thus are called empty elements in HTML. <p> tag contains text/paragraph in it so it’s not an empty element.
 
 

6. State true or false.

<p></p><p></p><p></p>produces numerous blank lines.

a) True
b) False
View Answer

Answer: b
Explanation: As a block tag, <p> induces a return by default, but when used repeatedly, like <p></p><p></p>, it does not have any effect on document.

7. Which of the following markup is correct?

i. <b><i>is in error as tags cross</b></i>
ii. <b><i>is not since tags nest</i></b>

a) i
b) ii
c) i and ii
d) Neither i nor ii
View Answer

Answer: b
Explanation: In markup, tags can be nested. The first tag who is going to nest other tag must end after that nested tag which means if <i> tag is nested in <b> tag then <b> must be closed after closing of the <i> tag.

8. Which of the following is not a correct (X)HTML rule?
a) Attributes should be quoted
b) Tags should not nest tag
c) Attribute minimization is forbidden
d) Unknown attributes are not ignored by the browser
View Answer

Answer: d
Explanation: Rules of XHTML are as- 1) XHTML elements must be properly nested
2) XHTML elements must always be closed
3) XHTML elements must be in lowercase
4) XHTML documents must have one root element
5) Attribute names must be in lower case
6) Attribute values must be quoted
7) Attribute minimization is forbidden

9. Choose the incorrect escape character entity.

a) &gt;
b) &#62;
c) &lt;
d) &st;
View Answer
Answer: d
Explanation: Character escapes in markup is to represent any Unicode character in HTML, XHTML or XML using only ASCII characters. There are different types of escape character entity in HTML. Some of them are > which is used for greater than(>) , > is basically a entity number which is used for greater than(>), < stands for less than(<), etc. There doesn’t exist any &st escape character entity in markup.
 
 

10. Identify the count of mistakes in the following markup.

<html>
<head>
</head>
<body>
<li>
   <ul><p>Hello</p></ul>
</li>
<br>
<hr>
</body>
</html>

a) 2
b) 3
c) 1
d) 0
View Answer

Answer: b
Explanation: We can write <p></p> tag in <ul></ul> tag as there is no such rule or else limitation. The tags <br> and <hr> are closed by default in browser.

Sanfoundry Global Education & Learning Series – HTML.

To practice all areas of HTML for Interviews, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.