Academic Tutorials



English | French | Portugese | German | Italian
Home Advertise Payments Recommended Websites Interview Questions FAQs
News Source Codes E-Books Downloads Jobs Web Hosting
Chats

CSS 2.0
CSS 2.0 Introduction
CSS 2.0 Attaching Style
CSS 2.0 Applying Style
CSS 2.0 Key Concepts
CSS 2.0 Color Contents
CSS 2.0 Fonts Contents
CSS 2.0 Text
CSS 2.0 Lists
CSS 2.0 the box model
CSS 2.0 Advanced concepts
CSS 2.0 Positioning
CSS 2.0 Boxes
CSS 2.0 Generated content
CSS 2.0 Dynamic effects
CSS 2.0 Tables
CSS 2.0 Paged media
CSS 2.0 Font Face
CSS 2.0 Aural Style Sheets
CSS 2.0 Language styles

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
CSS 1.0
CSS 2.0
HLML
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
CVS
Python
Apple Script
PL/SQL Tutorial
SQL Server
PHP
.NET (dotnet)
Microsoft.Net
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
VC++
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Matlab
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Graphics
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
SEO
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Eclipse
J2ME
JBOSS
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Cobol
Assembly Language
Mainframe
Forth Programming
Lisp Programming
Pascal
Delphi
Fortran
OOPs
Data Warehousing
CGI Programming
Emacs Tutorial
Gnome
ILU
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Oracle
MySQL
Operating System
BSD
Symbian
Unix
Internet
IP-Masquerading
IPC
MIDI
Software Testing
Testing
Firewalls
SAP Module
ERP
ABAP
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Netweaver
Customer Relationship Management
Production and Planning
Networking Programming
Corba Tutorial
Networking Tutorial
Microsoft Office
Microsoft Word
Microsoft Outlook
Microsoft PowerPoint
Microsoft Publisher
Microsoft Excel
Microsoft Front Page
Microsoft InfoPath
Microsoft Access
Accounting
Financial Accounting
Managerial Accounting
Network Sites


CSS 2.0 Properties - Color


Previoushome Next






CSS2 Properties - Color

A D V E R T I S E M E N T



Introduction

Two of the most important things in web design are color and backgrounds. It is hardly surprising therefore that CSS provides every possible means of changing them.

It should be noted that because of user and browser style sheets, if a background property or foreground color is specified, the corresponding foreground/background color must be explicitly stated - even if you assume that the values will inherit, they might not because the user style sheet may specifically state a particular color for a particular element.




Colors

There are 16 basic colors:

  • Aqua
  • Black
  • Blue
  • Fuchsia
  • Gray
  • Green
  • Lime
  • Maroon
  • Navy
  • Olive
  • Purple
  • Red
  • Silver
  • Teal
  • White
  • Yellow

Colors can also be specified as a hexadecimal number (hexadecimal (base-16) is similar to decimal, except instead of counting 8, 9, 10, it counts 8, 9, A, B, C, D, E, F, 10 (=16 decimal)):

#1CDBFA

The first two digits refer to the red component, the second two to the green, and the third to the blue. The maximum and minimum for each is FF and 00 respectively.

This can also be specified as a three digit hexadecimal number:

#C67

This is equivalent to #CC6677 (i.e., each digit is repeated to 'finish' the number).

Since different operating systems display colors in different ways, it is preferable to use web-safe colors. Web-safe colors are those that have as red, green and blue components only (in hex) 00, 33, 66, 99, CC or FF. This allows you to select one of 216 colors from a grid. Clicking on a color changes the background color of the page to that color, and you can then see what each of the 216 colors look like as a foreground so that you can easily get an attractive color scheme.

Alternatively, colors can be specified in this form: rgb (x%, y%, z%) (e.g. rgb (30%, 40%, 20%), or as a decimal number: rgb (x, y, z) (e.g. rgb (168, 57, 32)), where the maximum and minimum on most computers is 255 and 0 respectively.

IE 3 does not support colors in either the decimal format (rgb (x, y, z)) or the %.

User interface based colors

User interface based colorsIn order to make pages that conform to the operating environment that your users are used to, it is possible to declare all color values as one of the following (note that CSS is case-insensitive so the mixed caps are cosmetic only):

  1. ActiveBorder = active window border
  2. ActiveCaption = active window caption
  3. AppWorkspace = Background color of a multi-document interface
  4. Background = Desktop background color
  5. ButtonFace - button background color
  6. ButtonHighlight - highlight background color
  7. ButtonShadow - shadow background color
  8. ButtonText - button text color
  9. CaptionText - text in caption, size box, and scrollbar arrow box.
  10. GrayText - color of grayed out (disabled) items
  11. Highlight - selected item in a control background color
  12. HighlightText - highlighted text color
  13. InactiveBorder - inactive window border
  14. InactiveCaption - inactive window caption
  15. InactiveCaptionText
  16. InfoBackground - background color of popup help on icons
  17. Menu - Menu background
  18. MenuText
  19. Scrollbar - the area in which the scroller is dragged
  20. ThreeDDarkShadow - dark shadow of 3d display elements
  21. ThreeDFace
  22. ThreeDHighlight
  23. ThreeDLightShadow
  24. Window = window background
  25. WindowFrame
  26. WindowText

Examples

P {color: windowtext}
BODY {color: #C67}
LI {color: rgb(10%, 45%, 56.7%)}




Properties

Color

The 'color' property specifies the color of text in an element. For example, P {color: red} or P {color: #C624FF} would make all P elements (such as this one) red or purple respectively.

Color is inherited so if you specify that BODY should be red, everything inside BODY (such as this text) will also be red unless otherwise stated on the descendant elements. Color has an initial value that is browser determined (almost always black).

Background properties

These are not inherited.

Backgrounds fill the area behind the text when specified on inline elements such as B, whereas on block elements they color the whole of the background of the block.

Note that although backgrounds color padding, they do not color in margins, except on BODY/HTML.

IE 3 does not support background properties on linked style sheets on BODY, HTML and TABLE. This might make pages difficult or impossible to read. Therefore, I would recommend that you declare backgrounds using the BODY tag in the HTML (e.g., <BODY bgcolor="black">). Style sheets override HTML attributes, so you are not constrained by BODY.

In addition, it does not support the individual background properties, only the 'background' shorthand.

Background-color

This can be set to a color or transparent (initial value, meaning that the parent element's background-color shines through). E.g., P {background-color: transparent}

Netscape 4.* does not color in the whole of the background of block elements if they are given a background color that is different from BODY - it only colors the space behind the text. To avoid this, explicitly set border: none.

Background-image

Specified with background-image: url(NameOfFile), e.g. BODY {background-image: url(back.jpg)}. The other value is none, which is the initial value. E.g., background-image: none.

Background images are rendered on top of background colors.

Background-repeat

This states the tiling of the background image - normally backgrounds cover the whole of the element but using background-repeat you can alter this.

Possible values are repeat (tile the image left, right, up and down - initial value), repeat-x (tile the image left and right), repeat-y (tile the image up and down) or no-repeat (only draw the image once). For example, background-repeat: repeat-x.

IE only draws repeat-x to the right, and repeat-y down, not left and right and up and down as it should do.

Background-attachment

This can be specified as one of scroll (initial) or fixed. Scroll means that the background moves with scrolling, but fixed that it stays in the same place regardless of scrolling.

E.g., BODY {background-attachment: fixed}.

Background-position

This states the initial position of the background image. E.g., BODY {background-position: 12cm 100%}, where the lengths refer to the offset of the top left hand corner of the image from the element's padding's top left corner (the first distance is horizontal, the second vertical).

55% 67% means that the point 55% across and 67% down the image is placed 55% across and 67% down from the element's padding's top left corner. If only one percentage or distance is supplied, it refers to the horizontal value, with the vertical position set to 50%.

Lengths should be avoided because they vary on different resolution screens. The initial value is 0% 0%. Negative values are permitted.

Note in particular that changing the background position does not mean that it will not still fill the element - a background position of 90% 90% will fill the background as much as one of 0% 0% - the only difference will be that different parts of the background will be in different bits of the screen.

Alternatively, one or two keywords can be specified, being top (0%), center (50%), or bottom (100%) for the vertical position, and left (0%), center (50%) and right (100%) for the horizontal position - e.g., background-position: top center. As before, if you omit one, the other is set to center (=50%). Note as well that these keywords cannot be combined with lengths or %.

Note that background-position only applies to replaced and block elements.

Background

This allows one or more of the above properties to be specified in the order color, image, repeat, attachment, position. E.g., BODY {background: red url(back.gif) 10% 10% repeat-y}.

Because the background property is supported by more browsers than the longhand properties, you should use it instead. However, since Netscape defaults to black if you use the background property, you should always specify a background color when you use this property.



Be the first one to comment on this page.




  CSS 2.0 eBooks
More Links » »
 
 CSS 2.0 FAQs
More Links » »
 
 CSS 2.0 Interview Questions
More Links » »
 
 CSS 2.0 Articles

No CSS 2.0 Articles could be found as of now.

 
 CSS 2.0 News

No News on CSS 2.0 could be found as of now.

 
 CSS 2.0 Jobs

No CSS 2.0 Articles could be found as of now.


Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previoushome Next

Keywords: CSS2 Properties - Color, CSS2, css2, CSS2 tutorial, CSS2 tutorial pdf, history of CSS2, Custamizing Style Sheet, learn CSS2

HTML Quizzes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
CSS 1.0 Quiz
CSS 2.0 Quiz
HLML Quiz
XML Quizzes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizzes
JavaScript Quiz
VBScript Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizzes
ASP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
CVS Quiz
Python Quiz
Apple Script Quiz
PL/SQL Quiz
SQL Server Quiz
PHP Quiz
.NET (dotnet) Quizzes
Microsoft.Net Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
VC++ Quiz
Multimedia Quizzes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Photoshop Quiz
Gimp Quiz
Matlab Quiz
Gnuplot Programming Quiz
GIF Animation Quiz
Scientific Visualization Quiz
Graphics Quiz
Web Building Quizzes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Weblogic Quiz
SEO Quiz
Web Site Hosting Quiz
Domain Name Quiz
Java Quizzes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Eclipse Quiz
J2ME Quiz
JBOSS Quiz
Programming Langauges Quizzes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Cobol Quiz
Assembly Language Quiz
Mainframe Quiz
Forth Programming Quiz
Lisp Programming Quiz
Pascal Quiz
Delphi Quiz
Fortran Quiz
OOPs Quiz
Data Warehousing Quiz
CGI Programming Quiz
Emacs Quiz
Gnome Quiz
ILU Quiz
Soft Skills Quizzes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz
Database Quizzes
Oracle Quiz
MySQL Quiz
Operating System Quizzes
BSD Quiz
Symbian Quiz
Unix Quiz
Internet Quiz
IP-Masquerading Quiz
IPC Quiz
MIDI Quiz
Software Testing Quizzes
Testing Quiz
Firewalls Quiz
SAP Module Quizzes
ERP Quiz
ABAP Quiz
Business Warehousing Quiz
SAP Basis Quiz
Material Management Quiz
Sales & Distribution Quiz
Human Resource Quiz
Netweaver Quiz
Customer Relationship Management Quiz
Production and Planning Quiz
Networking Programming Quizzes
Corba Quiz
Networking Quiz
Microsoft Office Quizzes
Microsoft Word Quiz
Microsoft Outlook Quiz
Microsoft PowerPoint Quiz
Microsoft Publisher Quiz
Microsoft Excel Quiz
Microsoft Front Page Quiz
Microsoft InfoPath Quiz
Microsoft Access Quiz
Accounting Quizzes
Financial Accounting Quiz
Managerial Accounting Quiz
Testimonials | Contact Us | Link to Us | Site Map
Copyright 2008. Academic Tutorials.com. All rights reserved Privacy Policies | About Us
Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | Discussions World | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Indian Free Ads | Jobs Assist | New Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Webhosting in India | Dedicated Server in India | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Testing Interview Questions | Tests World | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World
Copyright 2003-2017 Vyom Technosoft Pvt. Ltd., All Rights Reserved.