<url>

This article needs a technical review. How you can help.

Summary

The <url> 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 <url> 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 <uri> 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 <url> CSS data type and no more the more generic <uri> CSS data type.

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

Many CSS properties take a URL as value, such as background-image, cursor, @font-face, list-style etc.  

The url() functional notation

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

Syntax

 <a_css_property>:  url("http://mysite.example.com/mycursor.png")

 <a_css_property>:  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

Specification Status Comment
CSS Values and Units Module Level 3
The definition of '<url>' in that specification.
Candidate Recommendation No significant change from CSS Level 2 (Revision 1)
CSS Level 2 (Revision 1)
The definition of '<uri>' in that specification.
Recommendation No significant change from CSS Level 1
CSS Level 1
The definition of '<url>' in that specification.
Recommendation  

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

Document Tags and Contributors

 Last updated by: stevemao,