Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

url() function for HTML background

Tags:

html

css

div {  background:url(smiley.gif) top left no-repeat }

What is this url()? I can't find documentation online.

(See http://www.w3schools.com/cssref/css3_pr_background.asp.)

like image 648
Randomblue Avatar asked Sep 03 '11 03:09

Randomblue


2 Answers

In your example url is the url of the image that will be used as the background for the div tag.

MDN has a decent explanation of it: https://developer.mozilla.org/en/CSS/uri

MDN is usually more up-to-date than W3Schools.

like image 85
Alexander Kahoun Avatar answered Sep 21 '22 08:09

Alexander Kahoun


It's the URL of the background image.

For example, lets say you've your images stored at /images and you've a background image called background.png located at /images/background.png, then you do:

background-image: url('/images/background.png');
like image 36
Ben Avatar answered Sep 22 '22 08:09

Ben