HTML Question-Answer

  1. HTML tags and HTML elements are the same thing?
  2. 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.

  3. What are tags and attributes in HTML?
  4. 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">Questions And Answer</p>, in this the 'align' is the attribute and 'p' is a tag.

  5. What are void elements or empty elements in HTML?
  6. Answer: HTML elements which do not have closing tags or do not need to be closed are known as void elements or empty elements. For Example <br>, <img>, <hr>, etc.

  7. What is the difference between <strong>, <b> tags and <em>, <i> tags?
  8. 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 tags don't say anything about the text.
    Whereas, <strong> and <em> tags represent that the text is of strong importance or more importance than the rest of the text.

  9. Difference between Inline and Block elements:
  10. 1. Inline elements occupy only sufficient width required.
    1. Block Elements occupy the full width irrespective of their sufficiency.

    2. Inline elements don't start in a new line.
    2. Block elements always start in a line.

    3. You can't set width and height values.
    3. You can set width and height values

    4. Inline elements, Only left and right margins can be applied.
    4. Block elements accepts margins from all sides.

    5. Inline elements are generally used to give inline styles and effects.
    5. Block elements like div and semantic tags are extensively used for defining layouts of the webpage.

    6. Exmples: <span>, <a>, <button>, <img> etc
    6. Exmples: <div>, <h1>, <p>, &ol;> etc

  11. How is Cell Padding different from Cell Spacing?
  12. 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.

  13. How can we merge two or more rows or columns into a single row or column in an HTML table?
  14. HTML provide table td attributes 'rowspan' and 'colspan' to merge different rows and columns.

  15. Can we display a web page inside a web page or Is nesting of webpages possible?
  16. Yes, we can display a web page inside another HTML web page, using <iframe> tag. HTML iframe tag

  17. What are HTML Entities?
  18. In HTML some characters are reserved like '<', '>', '/', '&', etc. To use these characters in our webpage we need to use the character entities called HTML Entities. List of HTML Entities

  19. Describe HTML layout structure.
  20. 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:

    • header: Stores the starting information about the web page.
    • footer: Represents the last section of the page.
    • nav: The navigation menu of the HTML page.
    • article: It is a set of information.
    • section: It is used inside the article block to define the basic structure of a page.
    • aside: Sidebar content of the page.

  21. Can a web page contain multiple <header> and <footer> elements?
  22. Answer: Yes, You can use multiple <header> and <footer> in one page, but there can be only one direct child, but you can use other ones in specific containers such as <article> which can have semantic <header> and <footer> attached, to avoid confusion to search engine.

  23. How to optimize website (increase loading speed)?
  24. To optimize website load time we need to optimize its asset loading such as:

    • CDN hosting - A CDN or content delivery network is geographically distributed servers to help execute fast.
    • File compression - This is a method that helps to reduce the size of an asset to reduce the data transfer
    • File concatenation - This reduces the number of HTTP calls
    • Minify scripts - This reduces the overall file size of js and CSS files
    • Lazy Loading - Instead of loading all the assets at once, the non-critical assets can be loaded on a need basis.

  25. How to specify the link in HTML and explain the target attribute?