CSS - Background Image


CSS - Background Image

  • In CSS, the background-image property is being used to set the background image for the body.

Sample Code :

<!DOCTYPE html>
<html>
    <head>
        <style>
            body 
            {
                background-image:
                    url("http://www.wikitechy.com/img/logo.png");
            }          
        </style>
    </head>
    <body>
        This is wikitechy logo!
    </body>
</html>

 Code Explanation :


    The background-image property specifies an image to use as the background for the element. URL specifies the location path of the background image.

    Here we have “This is wikitechy logo!” which have been called inside the body tag (<body> </body>).

Output :


    The text “This is wikitechy logo!” was displayed in the browser window as shown.

    Here, the background image wikitechy.com was displayed in the output.

Note :  The wikitechy.com image appears repeatedly over here in this output which is nothing but the REPEAT PROPERTY IN CSS which we will learn in the forthcoming concepts of CSS.