matt
matt

Reputation: 44293

HTML5 closing tag /> for meta or stylesheets

There are certain doctypes that need the closing tag /> and there are others that need just a >.

For example, <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
or <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" >

How is this with HTML5? Is it anything I need to consider?

Upvotes: 4

Views: 825

Answers (1)

Dennis
Dennis

Reputation: 482

Tags that have an opening and closing tag (anchors, span, divs, etc) don't need a /> because the / is in the closing tag.

Tags that stand alone (br, hr, img, etc.) are supposed to have a /> now.

As far as I understand, it's not necessary, but was put in play for HTML5 for the sake of consistency with XML and XHTML.

I have read that you should put a space before the /> as to not confuse older browsers.

Upvotes: 3

Related Questions