Web Development Tutorials.com

How to position a background image using pixels


Click Here for CoffeeCup Website Design Software   GoDaddy.com Hosting & Servers

The below HTML and CSS code example shows you how to position a background image using pixels.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>this is the title of the web page</title>

<style type="text/css">

body
{
background-image:
url('image.jpg');
background-repeat: no-repeat;
background-position: 10px 10px;
}


</style>

</head>
<body>

<p>
This web page has a background image that is positioned by using the background-position attribute with pixel values.
</p>

</body>
</html>

The following link is the web page that the HTML and CSS code above creates: CSS background image example.

The image below is the one that is used for the tutorial example page:

CSS background image tutorial example

You can the following image file (image2-w500h44.jpg) and the text editor below to practice positioning a background image using using pixels.