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,856
  • 10
  • 40
  • 79

3 Answers3

18

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,830
  • 1
  • 18
  • 16
awiebe
  • 3,758
  • 4
  • 22
  • 33
15
  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,959
  • 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,824
  • 1
  • 36
  • 46
Rohit Azad Malik
  • 31,410
  • 17
  • 69
  • 97