Câu hỏi phỏng vấn HTML
Câu hỏi

What is an optional tag?

Câu trả lời

An optional tag in HTML is a tag that can be omitted from the code because the browser is capable of inferring its presence from the context of the document. This concept is part of HTML5, which aims to make the code more human-readable by reducing redundancy and simplifying the structure where possible.

For example, the <html> tag is considered optional because when a document is displayed in a browser, it is inherently understood to be an HTML document. Similarly, the <head> and <body> tags can be omitted in certain contexts because elements such as <title> are only valid within the head, and elements like <p> (paragraphs) and <form> are only valid within the body of the document. The browser automatically infers these tags based on the placement of other elements that are explicitly included[1].

However, while the HTML5 specification allows for these omissions, there are practical considerations to keep in mind. Omitting tags can affect the readability of the code for other developers and can also impact the ability to specify certain attributes, such as the lang attribute on the <html> tag, which is important for accessibility and search engine optimization[2].

Additionally, while omitting c...

middle

middle

Gợi ý câu hỏi phỏng vấn

junior

What is the difference between span and div?

middle

How do you serve a page with content in multiple languages?

senior

Why you would use a srcset attribute in an image tag? Explain the process the browser uses when
evaluating the content of this attribute.

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào