url()
A reference to a file: an image, a font, a style sheet.
Syntax
url(path)Parameters
| Parameter | Type | Description |
|---|---|---|
| path | string | An address, absolute or relative; quotes are optional unless it contains spaces or brackets. |
Examples
An image as a background:
<div style="height: 100px; background: url(/media/photo-600x200.jpg) center / cover;"></div>Notes
A relative path inside a CSS file is counted from the CSS file, not from the HTML page. If the image does not load, check this first.
See also
- background-image — One or more background images: files or gradients.
- @font-face — Loads a font and gives it a name to use in `font-family`.
- @import — Includes another CSS file into the current one.
In the tutorial
- Backgrounds and borders — Background images, their repeat, size and position, border styles, rounded corners and outline.