Again while typing I read this question but that's a different one...and that too is not solved yet, as the person who's answer is marked as correct, says this in the end
I don't know direct answer to your question, but I'm pretty curious about tag, too. Finding answer would probably include some web archives digging.
So the question is quiet simple, why are we using src
attribute for <script>
tag but href
for a <link>
tag, now that confuses me many times when am including stylesheets and scripts...why it can't be same? any specific reason for this?
For example
<script href="#"></script>
<link href="#" />
Or
<script src="#"></script>
<link src="#" />
Definition and Usage. The href attribute specifies the URL of the page the link goes to. If the href attribute is not present, the <a> tag will not be a hyperlink. Tip: You can use href="#top" or href="#" to link to the top of the current page!
HREF - Hyperlink Reference | Often used in tags to reference another page or web link. SRC - Source | Often used in tags to give the web page the source of an image, video or file.
The href attribute specifies the location (URL) of a resource, that an anchor element points to, or the location of a linked resource, like a stylesheet. While the src attribute is used to embed a resource - usually URLs - into a document, think embedded images ( <img> ) and <script> tags.
The href property sets or returns the URL of a linked document.
A link points somewhere via a hypertext reference (hence href
). This is why we use <a href
too.
A script takes its source from elsewhere and is embedded into the current page, hence src
. Compare <img src
EDIT: Of course, another equally valid answer would be "It just does!" :p
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With