background-image using the url function, which takes the URL of a file as its only parameter : url « Style Basics « HTML / CSS






background-image using the url function, which takes the URL of a file as its only parameter

 
. 


<html>
<head>
<title>Set URL for Background Image </title>
    <style type="text/css">
        div { background:url("http://www.java2s.com/style/logo.png") no-repeat; width:250px; height:76px; } 
    </style>
</head>
<body>
<h1>Background Image</h1> 
<div></div> 
</body>
</html>

 








Related examples in the same category

1.list-style-image: url('collapsed_folder.gif');
2.you only have to put a URL in quotes if the URL contains whitespace.