HTML Questions and Answers | HTML Interview Questions and Answers

1. What does HTML stand for?

Answer: HTML stands for HyperText Markup Language.

2. What is HTML?

Answer: HTML stands for HyperText Markup Language and is the language of the World Wide Web. It is the standard text formatting language used for creating and displaying pages on the Internet.HTML is used to structure the website and is therefore used for Web Development.

3. Describe HTML.

Answer: Hypertext Markup Language or HTML is a markup language that is used to create Webpage to present the content on the World Wide Web. HTML pages are saved by adding .html or .html in web page name.

4. What are HTML tags?

Answer: We use HTML tags for placing the elements in the proper and appropriate format. Tags use the symbols <, and > to set them apart from the HTML content.

Tags are the starting and ending parts of an HTML element. They begin with < symbol and end with > symbol. Whatever is written inside < and > are called tags.

We add attributes right after the name of the HTML tag, inside the brackets. We can only add the attributes to opening or self-closing tags, but never be in closing tags.

5. What is the role of tags in HTML?

Answer:  “Tags” provide web browsers instructions about the web page, such as where to display images, and how the document is structured. Tags are always enclosed in angle brackets: < >.

6. What is an element in HTML?

Answer: An element in HTML is a set of tags that define a specific part of a web page. It consists of a start tag, content, and an end tag.

7. Are the HTML tags and elements the same thing?

Answer: 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.

8. Define HTML Attributes?

Answer: Attributes are the properties that can be added to an HTML tag. An attribute is used to provide extra or additional information about an element.

These attributes change the way the tag behaves or is displayed. For example, <img> tag has src attribute, which weuse to add the source from which the image should be displayed.

9. What are tags and attributes in HTML?

Answer: 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”>Hello World</p>, in this the ‘align’ is the attribute using which we will align the paragraph to show in the center of the view.

10. What is the role of the <head> tag in HTML?

Answer: The <head> tag defines information about the web page that is not displayed on the page itself, such as its title, keywords, and other metadata. It is located between the <html> and <body> tags and is usually the first element in the document.

11. What is the role of the <title> tag in HTML?

Answer: The title tag is an HTML code tag that allows us to give a web page a title. This title can be found in the browser title bar.

12. What is the significance of <head> and <body> tag in HTML?

Answer: <head> tag provides the information about the document. It should always be enclosed in the <html> tag. This tag contains the metadata about the webpage and the tags which are enclosed by head tag like <link>, <meta>, <style>, <script>, etc. are not displayed on the web page. Also, there can be only 1 <head> tag in the entire Html document and will always be before the <body> tag.

<body> tag defines the body of the HTML document. It should always be enclosed in the <html> tag. All the contents which need to be displayed on the web page like images, text, audio, video, contents, using elements like <p>, <img>, <audio>, <heading>, <video>, <div>, etc. will always be enclosed by the <body> tag. Also, there can be only 1 body element in an HTML document and will always be after the <head> tag.

13. How can we comment in HTML?

Answer: Comments are used by developers to keep a track of the code functionality and also help the other developers in understanding the code functionalities easily.

The commented outlines will not be shown in the browser. To comment a line, the line should start by this <!– and end by this –>. Comments can be of one line or of multiple lines.

14. What are <br> tags in HTML?

Answer: <br> tags are used to enter a new line into the HTML contents. These tags are generally used to separate two different lines of text between each other.

15. How many types of heading does an HTML contain?

Answer: The HTML contains six types of headings which are defined with the <h1> to <h6> tags. Each type of heading tag displays different text size from another. <h1> is the largest heading tag and <h6> is the smallest one.

16. Define the list types in HTML?

Answer: There are three lists in HTML: ordered, unordered, and definition.

  • Ordered list: Ordered lists are numbered lists. The ordered list uses <ol> tag and displays elements in a numbered format. An Ordered List or ol tag, lists the items in an ordered way, i.e. numbered or alphabetically.
  • Unordered list: Unordered lists are bulleted lists. The unordered list uses <ul> tag and displays elements in a bulleted format. An Unordered List or ul tag list the items in an unordered way.
  • Definition list: Definition lists are lists of terms and their definitions. Definition list uses <dl>, <dt>, <dd> tags and displays elements in definition form like in a dictionary.

17. Differentiate between an Ordered list and an Unordered list?

Answer: An unordered list uses <ul> </ul> tags and each element of the list is written between <li> </li> tags. The list items are displayed as bullets rather than numbers.

An ordered list uses <ol> </ol> tags and each element of the list is written between <li> </li> tags. The list items are displayed as numbers rather than bullet points.

18. What is a marquee in HTML?

Answer: Marquee is used for scrolling text on a web page. It scrolls the image or text up, down, left, or right automatically. To apply for a marquee, you have to use </marquee> tags.

19. How do you insert a copyright symbol in HTML?

Answer: We can insert a copyright symbol by using &copy; or &#169; in an HTML file.

20.  How is Cell Padding different from Cell Spacing?

Answer: 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.

21. How can we create a hyperlink in HTML?

Answer: Anchor tag ( <a>) is used  to create a hyperlink in HTML that links one page to another page. The hyperlink can be added to images too. 

Hyperlinks can be displayed in three ways:

  • Unvisited Link – These links are blue in color and underlined.
  • Visited Link – These links are purple in color and underlined.
  • Active Link – These links are red in color and underlined.

22. How do you insert an image in the HTML webpage?

Answer: To insert image in an HTML page, use the <img> tags. It is an empty tag, containing only attributes since the closing tag is not required.

We should use the <img> tag inside <body>…</body> tag. The <img> tag specifies an image to be displayed in an HTML document. The srcattribute is used to add the image source which is the URL of the image (location of the file).

23.  What is the role of the alt attribute in HTML?

Answer: The alt attribute is used for displaying a text in place of an image whenever the image cannot be loaded due to any technical issue. The alt attribute provides alternative text for an image in case the image cannot be displayed.

24.  What is the difference between an absolute and relative URL?

Answer: An absolute URL includes the full web address, the protocol (such as http or https) and the domain name (such as www.example.com). A relative URL, on the other hand, specifies the location of a resource relative to the current web page. For example, a relative URL might include the file path (such as /images/picture.jpg) or the relative path (such as ../images/picture.jpg).

25. What is a form in HTML?

Answer: A form is a set of input fields and other elements to collect user data. Forms can be used for various purposes, such as logging in, submitting feedback, or purchasing. Forms in HTML are required when we want to collect the user information.

26.  What are the different types of form input fields in HTML?

Answer: Several form input fields in HTML include text fields, checkboxes, radio buttons, select menus, and text areas. Each input field type is used to collect different types of data from users.

27. What is the role of the action attribute in HTML forms?

Answer: The action attribute is used to specify the URL of the script or program that will process the data submitted by the form. When the user clicks the submit button, the form data is sent to the specified URL for processing.

28.  What is the role of the method attribute in HTML forms?

Answer: The method attribute is used to specify the HTTP method that will be used to submit the form data. The two most common methods are GET and POST. GET is used to retrieve data from the server, while POST is used to send data to the server

3 thoughts on “HTML Questions and Answers | HTML Interview Questions and Answers”

  1. Henof This is really interesting, You’re a very skilled blogger. I’ve joined your feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!

    Reply

Leave a Comment