What’s the difference between ending a void element with
<link rel="stylesheet" href="./styles.css" />
or ending it with
<link rel="stylesheet" href="./styles.css" >
What’s the difference between ending a void element with
<link rel="stylesheet" href="./styles.css" />
or ending it with
<link rel="stylesheet" href="./styles.css" >
First one is from old version of html called XHTML and the second one is from new version of html called HTML5.
Thank you, I was just confused because the curriculum uses the first one, but my web design teacher says that the second is correct.
They are both “correct” in some sense.
The browser ignores the slash.
Prettier adds it by default.
React developers often add it out of habit, or because they prefer the formatting.
Most HTML validators will warn about it, but will still validate the HTML.
Trailing slash on void elements has no effect and interacts badly with unquoted attribute values.
Thank you!
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.