css url,url_CSS_w3cschool

url

The CSS data type denotes a pointer to a resource. It has no proper syntax and can only be expressed through the url() functional notation.

URI or URL?

There is a difference between a URI and a URL. A URL describes the location of the resource, the URI describes an id of the resource . A URI may be a location, a URL, or a name, a URN, of a resource.

In CSS Level 1, the url() functional notation was introduced to describe... URL, i.e. locations (a CSS data type, though it wasn't explicitly defined that way).

In CSS Level 2, the same functional notation was extended to describe any URI, being a URL or URN. This led to the confusing fact that url() was used to create a CSS data type. Not only was this confusing, but URN are almost never used in the CSS usual case.

To fix this, CSS Level 3 came back to the initial definition, this time explicitly defined. The functional notation url()denotes a CSS data type and no more the more generic CSS data type.

Remark that these semantic details doesn't change much for a web author, or the implementation details of the data type.

The url() functional notation

The URL may be unquoted, or quoted by single or double quotes. Relative URLs are allowed and are relative to the URL of the stylesheet (not to the URL of the web page).

Syntax : url("http://mysite.example.com/mycursor.png")

: url(http://mysite.example.com/mycursor.png)

Note: Control characters above 0x7e are no longer allowed in unquoted url() notation starting in Firefox 15. See bug 752230 for more details.

Examples .topbanner { background: url("topbanner.png") #00D no-repeat fixed; } ul { list-style: square url(http://www.example.com/redball.png) }

Specifications

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)

Basic support 1.0 1.0 (1.0) 3.0 3.5 1.0 (85)

Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile

Basic support 1.0 1.0 (3.5) yes yes 1.0

© 2005–2017 Mozilla Developer Network and individual contributors.

Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

https://developer.mozilla.org/en-US/docs/Web/CSS/url

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值