11

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?

Community
  • 1
  • 1
OneChillDude
  • 7,558
  • 10
  • 37
  • 76

3 Answers3

17

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.

Rick
  • 3,765
  • 1
  • 16
  • 16
awiebe
  • 3,649
  • 4
  • 20
  • 32
14
  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.
behnam
  • 1,899
  • 14
  • 21
  • 2
    more information in here: http://stackoverflow.com/questions/3395359/difference-between-src-and-href – John Yin Feb 04 '14 at 10:31
0

it's very simple

you can use href for links as follows:
<a href="http://www.google.com/">Click here</a>
<link href="mystylesheet.css" type="text/css">

Now use to src put the links into html like this:
<img src="mypic.jpg">
<script src="script.js"></script>

GottZ
  • 4,671
  • 1
  • 37
  • 44
Rohit Azad Malik
  • 30,330
  • 17
  • 61
  • 93