Page 112 - DCAP408_WEB_PROGRAMMING
P. 112
Web Programming
Notes
Example: How to set the height of the image using pixel.
Source Code Result
4.4.12 Color/Background Properties
Color and Background properties allow color control of both the foreground and background
of an element’s rendering box. The background properties also allow sophisticated placement
and control of images to create background textures. The color and background capabilities
behaviors originally available in HTML have been absorbed in to these CSS properties and
greatly expanded.
Setting Colors
Basically you have three color options with CSS:
1. Setting the foreground color for contents
2. Setting the background color for an area
3. Setting a background image to fill out an area.
In plain HTML, colors can either be entered by name (red, blue etc.) or by a hexadecimal color
code (for example: #FF9900).
With CSS you have these options:
1. Common name: You can define colors with the use of common names, by simply enter the
name of the desired color.
For example: .myclass {color:red; background-color:blue;}
2. Hexadecimal value: You can define colors with the use of hexadecimal values, similar to
how it's done in plain HTML.
For example: .myclass {color:#000000; background-color:#FFCC00;}
106 LOVELY PROFESSIONAL UNIVERSITY