| Property Name | Some Possible Values | What It Does |
|---|---|---|
| background | (All background properties at once) | Sets background |
| background-color | (Any color) | Background color |
| background-image | url('example.jpg') | Background image |
| background-repeat | repeat-x | repeat-y | no-repeat | Tile background? |
| background-position | top left | 50% 100% | Position? |
| background-attachment | fixed | scroll | Fixed or scroll? |
background is written as follows:background: color image repeat position attachment;color = Any named color or hexadecimal color code.
red | green | navy | #ffffcc | #000000image = Path to any background image file.
url("background.jpg")repeat = A value that defines how the background image is repeated. repeat-x | repeat-y | no-repeatposition = A pair of values that set the background image's position. left top | center center | right bottomattachment = Any value(s) applicable to background-attachment. fixed | scrollbackground property is declared and then followed by a space-separated list of values pertaining to any one or more of the above.background: orange url("test.jpg") no-repeat center center fixed;background shorthand property can be set individually using the following CSS properties:red, green, blue, #ffffcc, etc. (Please see font color for more about what colors you can use for any HTML or CSS code.) background-color: silver;url("path to any image file") where path to any image file equals any relative or absolute path to the image file you wish to display as a background.background-image: url("mycoolpic.gif");
background-image: url("pics/mycoolpic.gif");
background-image: url("http://www.example.com/mycoolpic.gif");background-repeat property to control this behaviour. The value can be any one of the following:repeat-x - The background image is only repeated horizontally.repeat-y - The background image is only repeated vertically.no-repeat - The background image is only displayed once.background-repeat: repeat-x;
background-position to define exactly where the background image is displayed on your web page. left | center | righttop | center | bottombackground-position: 0% 50%;background-position: 50% 100%;background-position: 20px 40px;background-position: right bottom;bgproperties="fixed" in the <body> tag doesn't work in Firefox (or any Gecko-based browser for that matter) then here comes the CSS property background-attachment to the rescue. This can be used to make the background image remain fixed in place while the rest of the web page content scrolls over it.fixed | scroll<body style="background-attachment: fixed;" background="example.jpg">background shorthand property described above (height and padding are also defined for demonstrational purposes):<p style='background: orange url("sunset.jpg") no-repeat 0px 20px; height: 100px; padding: 20px;'>It was a beautiful sunset...</p>
Note that in the inline style above, we're obliged to nest one set of quotation marks within another to declare the path to the background image within thestyleattribute. If we used double quotation marks for bothstyle="..."andurl("..."), the web page would get messed up because thestyleattribute would end prematurely. Hence we'll opt to use single quotation marks for thestyleattribute [style=' '] and double quotation marks for the path to the background image [url(" ")].
<style type="text/css">
<!--
p {
background: orange url("sunset.jpg") no-repeat 0px 20px;
height: 100px;
padding: 20px;
}
-->
</style>
<p>It was a beautiful sunset...</p>
It was a beautiful sunset...
And the lowdown on what's happening here is:
- The height of the paragraph is 100 pixels.
- The padding on all sides of the paragraph is 20 pixels.
- The background color is orange.
- The background image is "sunset.jpg" and is:
- Not repeated (only displayed once).
- Set flush with the left border (0 pixels).
- Set 20 pixels from the top border.
Free Text Editors
Free Graphics Editors
Website Analysis Tools
Free Website Templates
See also:
Best Free Web Hosting
How to Make a Web Page
If you need a .COM web address, you can get one quick and easy at...
| <~ BACK | TOP | NEXT ~> |