body{
background-color: #000000;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 8pt;
color: #FFFFFF;
}
The above combination gives us a black background rather than the standard white, we have also set the font types we want the page to be displayed in at 8pt in size and to be white in color. View here to see the results of the above combination.
Now lets say you wanted to put an image on the background of your web page rather than a colour like we just did.
body{
background-image:(images/purpsky.jpg);
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 8pt;
color: #000000;
So with this combination we get our images that fills the background of out web document. Black text at 8pt and the font family is set to choose from the 5 listed. View it here to see what it looks like.
We can use this background styles on just about any HTML element we want to. We can add backgrounds to table tags, tr, td anything we would like to change the background on. To high light a paragraph we can even change the background on it so that it stands out.
We can control the way the image displays in our document as well with a series of style tags as well. Such as
BACKGROUND REPEAT
background-repeat: repeat;
This will tile the image until the entire page is filled, just like an ordinary background image in plain HTML.
background-repeat: repeat-x;
Repeats the image horizontally - but not vertically.
background-repeat: repeat-y;
Repeats the image vertically - but not horizontally.
background-repeat: no-repeat;
Does not tile the image at all.
BACKGROUND POSITIONING
Background positioning is done by entering a value for the left position and top position separated by a space.
background-position: 75px 75px;
In the example above the image is positioned 75 pixels from the upper left corner of the page.
FIXING BACKGROUNDS
You can fixate an image at a certain position so that it doesn't move when scrolling occurs.
background-attachment: fixed;
Pretty simple hey! and it also makes for a better standard of HTML in your document with different browser that render documents differently. Styles are more browser friendly was of changing your document.
And what about if we want to change the way the defaults set an anchor tag on our page. Well there under Pseudo elements so click here to check out how to change them.
|