Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > CSS

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

URLs

The URL function (<url>) is used to designate the address of a resource for use in a property such as background-image or list-style-image. The path of the resource follows the same rules as other uniform resource identifier (URI) usages like link href values in HTML. When using external style sheet documents, relative paths relate to the document the CSS rule is found in (the external CSS document) and not the source HTML document.

body { background-image: url(../images/bg_body.png); }
body { background-image: url(/images/bg_body.png); }
body { background-image: url(https://example.com/images/bg_body.png); }

URIs can be quoted with single or double quotes or can be left unquoted. For historical reasons dating back to IE for the Mac, single quotes are sometimes avoided as a best practice.

  • + Share This
  • 🔖 Save To Your Account