0

SRC in javascript and href in css

Hi, when linking css to html file, we use href as the attribute. Why then in javascript we use src? Cant we src in css also?

13th Mar 2019, 8:10 AM
Tan Fu Yu
Tan Fu Yu - avatar
4 ответов
+ 2
//Hey Tan Fu Yu src is to used to add that resource to the page, whereas href is used to link to a particular resource from that page. When you use <link href="style.css" rel=stylesheet" /> in your webpage, the browser sees that its a style sheet and hence continues with the page rendering as the style sheet is downloaded in parellel. When you use <script src="script.js"></script> in your webpage, it tells the browser to insert the resource at the location. So now the browser has to fetch the js file and then loads it.
13th Mar 2019, 9:20 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 2
//hey Tan Fu Yu src (Source) attribute just embeds the resource in the current document at the location of the element's definition but css href only makes a link relationship between html and css like src they don't embed source on page
13th Mar 2019, 9:41 AM
Sudarshan Rai
Sudarshan Rai - avatar
0
Shudarshan Rai 👑 hi raj thanks for the explanation. In that case why cant we use src for css too? It seems simpler and straightforwardly
13th Mar 2019, 9:36 AM
Tan Fu Yu
Tan Fu Yu - avatar
0
Shudarshan Rai 👑 so why cant css embed a resource into html too?
13th Mar 2019, 9:50 AM
Tan Fu Yu
Tan Fu Yu - avatar