CSS url() Function

❮ Previous Functions Next ❯

Example

.example1 {
  background: url(flowers.jpg);
}

.example2 {
  background: url("flowers.jpg");
}

.example3 {
  background: url('flowers.jpg');
}

Meaning

The url() css function specifies the parameter is an absolute URL, a relative URL, a blob URL, or a data URL.

Quotes are required if the URL includes parentheses, whitespace, or quotes, unless these characters are escaped, or if the address includes control characters above 0x7e. Double quotes cannot occur inside double quotes and single quotes cannot occur inside single quotes unless escaped.

The url() function can be passed as a parameter of another CSS functions, like the attr() function. Depending on the property for which it is a value, the resource sought can be an image, font, or a stylesheet.

The url() function can be included as a value for: background, background-image, border, border-image, border-image-source, content, cursor, filter, list-style, list-style-image, mask, mask-image, offset-path @font-face, and @counter-style

Version: CSS3




Standard Syntax

url(string)



Browser Support

The numbers in the table specify the first browser version that fully supports the property.




Status







Function Arguments

The following table describes the arguments of this function.

Argument Description
string Specifies a URL or the ID of an SVG shape.
  • url: Specifies a relative or absolute address, or pointer, to the web resource to be included, or a data URL, optionally in single or double quotes.
  • path: References the ID of an SVG shape — circle, ellipse, line, path, polygon, polyline, or rect — using the shape's geometry as the path.
❮ Previous Functions Next ❯