
Consider the above example. If we run the above HTML document we get a web page as below. The page background is white in color which is default (means if we don’t specify any color it will appear in the default white color).

Suppose if we want the background color to be pink then we can use the attribute bgcolor in the <body> start tag. It will change the background color to pink. So attributes are there to provide additional information on how or what to display on a web page.
Add the attribute “bgcolor” in the body tag as <body bgcolor="pink"> and save it with .html extension. See the below code for reference.

The attribute always comes in name=”value” pairs. In the above example bgcolor is the name and pink is the value. The values of the attributes should be placed within quotes always.
Now open the saved .html file from Internet Explorer. You could see that the background color has changed to pink as below.
No comments:
Post a Comment