Differences between 'url', 'src', and 'href'

38,892

Solution 1

  1. In CSS, it's always url.
  2. In HTML:
    1. It's href (short for Hypertext REFerence) for all kinds of links, including tags a and link.
    2. When it's not a link, you are setting the source, so it's src.

Solution 2

src -- I want to load up this resource for myself.

href -- I want to refer to this resource for someone else.

url -- A script wants to use this url as a variable.

Share:
38,892
OneChillDude
Author by

OneChillDude

Updated on August 20, 2022

Comments

  • OneChillDude
    OneChillDude over 1 year

    Possible Duplicate:
    Difference between SRC and HREF

    When writing html/css, it seems like these all do the exact same thing. Obviously this is not the case, and if you 'href' when your supposed to 'src' your gonna have a bad time. But my question is, is there an easy way to remember which ones do which, and when they are used?

  • BoltClock
    BoltClock over 11 years
    Not necessarily a variable. A URL is just that: a URL.
  • John Yin
    John Yin over 10 years
    more information in here: stackoverflow.com/questions/3395359/…
  • Premraj
    Premraj about 8 years
    url is value of src and href attribute