Page 152 - Digicode_AI_class_8
P. 152

You need to give complete drive path of the stylesheet, if the file is saved at any other location. Let
            us create a web page using the external style sheet. The first step is to create stylesheet file. Open
            the Notepad and type the following code:

            body{background-color:green; color:white;}

            Now, save the file with the name style.css at any location again open a new notepad window and
            type the following code:
            <!DOCTYPE html>

            <html>
            <head>

            <title> Using External Stylesheet</title>
            <link rel=”stylesheet” type=”text/css” href=”style.css”>

            </head>
            <body>

            Text with white colour and background colour is green
            </body>

            </html>
            When you view the preceding web page in browser, you will get the following output:



















            You can also use the 6 digits hexadecimal code in place of colour name. For example, the hexadecimal
            code #000000 represents the black colour and #FFFFFF represents the white colour.
            For example:

            body{background-color: #000000;}
            You can also set an image as background of a web page by using the background-image property of
            CSS in the following manner:

            body{background-image:url(“background.jpg”);}

            Cascading  Style  Sheets  (CSS)  is  a  convenient  method  of  styling  the  elements  of  a  webpage.  It
            controls various elements like the colour, font, text size, etc. within a single page or the entire
            website. CSS can also be used to change the look of any webpage elements such as paragraphs, lists,
            backgrounds, etc.


                150    DigiCode AI-VIII
   147   148   149   150   151   152   153   154   155   156   157