does the link element have a closing back slash or not
i.e is it
(1) <link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
(2) <link href="css/style.css" rel="stylesheet" type="text/css" media="all" >

Recommended Answers

All 5 Replies

If you use a (X)HTML strict doctype then you will have to use a closing backslash, but with HTML5 doctype for example you can use the second as well.

*forward slash

coz most sites including daniweb dont include the back slash, so was a bit confused on what is which. so with backlash it is. wish they had documented it in the html specification

Indeed a forward slash (or trailing slash), of course! @stacy_2 it has more to do with valid XML then HTML. XHTML (X stands for XML) disappeard slowly in favor of HTML5, so we don't need to be so strict anymore with the way we markup our pages.

HTML NEVER had a self closing element

XHTML required all elements to close, singleton elements were required to self close,
<img alt='' src='' /> or
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" /> or
<a href=''>link text</a>
XHTML is happily dead in favour of HTML5 the elements now look like
<link rel="stylesheet" href="theme.css"> type not required
<script src="scriptfile.js"></script> type not required
<img alt='' src=''>
<a href=''>link text</a>

It is properly documented in the HTML documentation
It is not mentioned:
That is entirely proper.
it is not; never was; never will be; part of the HTML specification.
It would be somewhat strange to reference everything(anything) that is not part of the specification

'Hey look, the service manual for my car, is in the HTML spec, as "not part of HTML" ' <<attempted humour<<

commented: exactly +9
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.