Why "src" and "href" are different?

Why "src" and "href" are different?
0.0 0


Don’t src and href both are used for the hyperlink. Is there any reason as to why these two are different and how exactly do they differ from each other?


src defines the source of something i.e. an image <img src="cat.jpg">

href defines where a link will take a user i.e. <a href="https://forum.freecodecamp.org">


Adding to what @hepsy said, you can also think of it as this:

href is used for links to webpages
src is used for images and scripts

They are not interchangeable as there is a differentiation to them. This stack overflow post does a good job of explaining the differences if you want to read into it more: https://stackoverflow.com/questions/3395359/difference-between-src-and-href