Differences between 'url', 'src',

2019-04-07 03:27发布

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?

标签: html css url href src
3条回答
Deceive 欺骗
2楼-- · 2019-04-07 03:39

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.

查看更多
叼着烟拽天下
3楼-- · 2019-04-07 03:55

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>

查看更多
我想做一个坏孩纸
4楼-- · 2019-04-07 04:00
  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.
查看更多
登录 后发表回答