HTML Interview Questions and Answers
HTML Interview Questions and Answers
No. HTML elements are defined by a starting tag, may contain some content and a closing
tag. For example, <h1>Heading 1</h1> is a HTML element but just <h1> is a starting tag
and </h1> is a closing tag.
Tags are the primary component of the HTML that defines how the content will be
structured/ formatted, whereas Attributes are used along with the HTML tags to define the
characteristics of the element. For example, <p align=” center”>Interview questions</p>, in
this the ‘align’ is the attribute using which we will align the paragraph to show in the center
of the view.
HTML elements which do not have closing tags or do not need to be closed are Void
elements. For Example <br />, <img />, <hr />, etc.
The class attribute is used to specify the class name for an HTML element. Multiple
elements in HTML can have the same class value. Also, it is mainly used to associate the
styles written in the stylesheet with the HTML elements.
5. What is the difference between the ‘id’ attribute and the ‘class’ attribute of HTML
elements?
Multiple elements in HTML can have the same class value, whereas a value of id attribute of
one element cannot be associated with another HTML element.
Every web page has different components to display the intended content and a specific UI.
But still, there are few things which are templated and are globally accepted way to
structure the web page, such as:
Strict Doctype
Transitional Doctype
Frameset Doctype
9. What is the difference between <strong>, <b> tags and <em>, <i> tags?
The effect on a normal webpage of the tags <strong>, <b> and <em>, <i> is the same. <b>
and <i> tags stands for bold and italic. These two tags only apply font styling and bold tag
<b>, just adds more ink to the text, these tags don't say anything about the text.
Whereas, <strong> and <em> tags represent that the span of text is of strong importance or
more importance and emphatic stress respectively than the rest of the text. These tags have
semantic meaning
Cell Spacing is the space or gap between two consecutive cells. Whereas, Cell Padding is the
space or gap between the text/ content of the cell and the edge/ border of the cell. Please
refer to the above figure example to find the difference.