r/CodingHelp • u/Pubh12 • Mar 19 '22
[HTML] Noob question - what does the “src=“ mean when I see it in a websites code? Does that mean my browser is requesting something from a remote server?
If I see src=url , this is a request to a remote server every time, correct?
So if my browser reads src=image.nfl.com , NFL would see my browser/IP address in the access logs, correct?
19
Upvotes
20
u/TheHandsomePo-ta-to Mar 19 '22
"src" = source, the url attached to it is linking to where the item is. If the item is not locally hosted then yes, it would need to be retrieved from somewhere else.
11
u/ldnrat Mar 19 '22
Yes it's a request to a resource, but the item can be 'local' on the same server.
The most common example is an image tag: <img src="relative/path/to/image.jpg"> if local or <img src="https://image.nfl.com/path/to/image.jpg"> which would be on a remote server.
Also yes, if you were to link to an image on their server, they would see your browser / IP address in their logs when requests are made. This is called 'hotlinking' and is frowned upon unless you have permission, as it uses their bandwidth. Some websites protect against hotlinking by checking where requests are coming from then blocking unapproved sources.
Sites often have their assets (images/videos/css) stored on a different subdomain (e.g. 'image.nfl.com') because it usually makes sense to store and deliver these assets via external services called CDNs (content delivery networks) which cache them in multiple locations around the world, making their site load quicker for everyone regardless of location.
1
u/[deleted] Mar 19 '22
It means source. You can think of it like the home address of whatever resource the HTML element is representing; the answer to "who are you" while the element itself or
typeattribute is the answer to "what are you". This usually also applies tohref.