Are XHTML tag tags valid in HTML?

Are XHTML style tag tags valid in HTML? I mean, in XHTML we use <link href="style.css" type="text/css" rel="stylesheet" />. Is it really in HTML? or should i use <link href="style.css" type="text/css" rel="stylesheet"></link>?

+3
source share
3 answers

They are not valid in HTML4 for an element LINK.

Start tag: required, End tag: prohibited

But XML style tags, as in your question, valid in HTML5:

Authors may optionally choose to use the same syntax for void elements in the HTML syntax.

, HTML5 XML/XHTML. HTML5. XHTML application/xml+html, IE. text/html <!DOCTYPE html> , .

+3

<link> HTML. <link/> XHTML. XHTML text/html, , HTML, XHTML, HTML, XHTML, Content-Type - text/html, XHTML.

HTML- xhtml HTML, , .

, , script , link . - w3.

+1

To quote the W3 validator regarding self-closing tags:

A sequence can be interpreted in at least two different ways, depending on the DOCTYPE of the document. For HTML 4.01 Strictly, '/' completes the tag '). However, since many browsers do not interpret it this way, even with HTML 4.01 Strict DOCTYPE, it is best to completely exclude it in pure HTML documents and reserve its use exclusively for those written in XHTML.

+1
source

Source: https://habr.com/ru/post/1765721/


All Articles