ad

Thursday, 26 June 2014

CSS Background

C.S.S. Background


This post is all about the background of the webpages, and how we can use C.S.S. to make an attractive background.
But before implementing C.S.S.  for your background make your that the color of background or image that is used by you as background does not make your text unreadable, the text should be clear and grabs the attention of the viewer which is very important.

                                                               Background Color

The background-color property specifies the background color of an element.

The background color of a page is defined in the body selector by using the body selector you can select the whole body:-
body{
background-color: blue;

                                                    Using Image as Background

Using Image as background can increase the attractiveness of the webpage. 

By default, the image is repeated so it covers the entire element.
Default means that the way browser interpret it, different browser can interpret it differently,but in this case most of the browser repeat the image so it cover entire element.
  The background image for a page can be set like this:-

body {
    background-image: url("paper.gif");
}



You can also set your image position and you can also set repeat or no repeat.
It can be done as
body {
    background-image: url("img_tree.png");
    background-repeat: no-repeat;
    background-position: right top;
}
You can also use the selectors if you want to give background color to specific text, line, paragraph.

CSS Selectors


                            C. S. S. Selectors

CSS selectors allow you to select and manipulate HTML elements.

CSS selectors are used to "find" (or select) HTML elements based on their id, classes, types, attributes, values of attributes and much more.

                          The element Selector

The element selector selects elements based on the element name.
You can select all <p> elements on a page like this: (all <p> elements will be center-aligned, with a red text color)
             p{
                     text-align:center;
                      color:red:
                    }

                                   The id Selector

The id selector uses the id attribute of an HTML tag to find the specific element.
An id should be unique within a page, so you should use the id selector when you want to find a single, unique element.
To find an element with a specific id, write a hash character, followed by the id of the element.
The style rule below will be applied to the HTML element with id="para1":
      #para1 {
    text-align: center;
    color: red;
        }
 NOTE:  DO NOT START ID WITH A NUMBER

                                The class Selector

The class selector finds elements with the specific class.
The class selector uses the HTML class attribute.
To find elements with a specific class, write a period character, followed by the name of the class:
In the example below, all HTML elements with class="center" will be center-aligned:
                   .center {
         text-align: center;
        color: red;
    }