Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

url()

A reference to a file: an image, a font, a style sheet.

Syntax

url(path)

Parameters

ParameterTypeDescription
pathstringAn 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.

Thanks for reading!

Donate to the site — we work hard for you.