Html Interview Questions and Answers

1. What is HTML?
HTML, which stands for HyperText Markup Language, is the standard markup language used to create and design documents on the World Wide Web. It forms the backbone of most web content, providing the basic structure for web pages. HTML allows you to organize and format the various elements on a web page, such as text, images, links, forms, and more.

2. What are tags and attributes in HTML?
In HTML, tags are elements enclosed in angle brackets that define the structure and content of a web page. They typically come in pairs, with an opening tag and a closing tag, encompassing the content to be affected. For example,<p> denotes a paragraph. Some tags, like <br> or <hr> , don’t have a closing tag. Attributes provide additional information about HTML elements and are included in the opening tag. They consist of a name and a value, modifying the element’s behavior or appearance. For instance, the <a> tag for links may include an href attribute with a URL value. Understanding how to use tags and attributes is essential for creating well-organized and functional HTML documents.

What is the difference between the ‘id’ attribute and the ‘class’ attribute of HTML elements?
‘Id’ must be unique, identifying a single element, while ‘class’ can be shared among multiple elements for common styling.

Define multipart form data?
Multipart form data is a content type used in HTTP requests to send binary or textual data, often associated with file uploads in web forms.

What type of audio files can be played using HTML5?
HTML5 supports the following three types of audio file formats:

  • Mp3
  • WAV
  • Ogg

Do all HTML tags come in a pair?
No, there are single HTML tags that do not need a closing tag. For Examples: <img> tag and <br> tags etc.

What is the use of a span tag? Explain with example.
The span tag is used for following things:

For adding color on text
To add background on text
Highlight any color text