Home arrow Style Sheets arrow Page 2 - Learn CSS, Manipulating Colors

Learn CSS, Manipulating Colors

In the thrid part of this series still covering CSS Basics, Michael Youssef discusses manipulating colors in CSS. He also takes a brief look at the hexadecimal number system and how it's useful with color values. He also defines the meaning of a keyword and the Hexadecimal number system.

Author Info:
By: Michael Youssef
Rating: 4 stars4 stars4 stars4 stars4 stars / 22
May 30, 2005
  1. · Learn CSS, Manipulating Colors
  2. · Keywords
  3. · Using RGB Color Values
  4. · Haxadecimal Color Values
  5. · CSS Comments

print this article

Learn CSS, Manipulating Colors - Keywords
(Page 2 of 5 )

  font-family: Tahoma;
  color: mediumslateblue;
  font-size: 1em;
  border: 2px solid greenyellow;
  background-color: lavender;
  font-size: .7em;

And here's the HTML code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <link rel="stylesheet" href="paragraph.css" type="text/css">
    <title>Colors with CSS</title>
    <h1>What's CSS?</h1>
    <p> CSS is a powerful formatting language for the web that is being used with markup languages like HTML, XHTML and XML and that's because the natural of the language. CSS uses the markup element name for applying formatting styles.</p>
    <h1>CSS and Markup Languages</h1>
    <p>You can't use css as a stand-alone styling language because you need something to style, like HTML or XHTML page.</p>


When you run this page, you will get the following result.

As you can see, we have been using the CSS 3.0 new named colors to color the background of the <h1> element to lavender, the border of <h1> to greenyellow and the color of the text of the <body> element to mediumslateblue.

The term "named colors" leads us to the concept of keywords, which is more related to programming languages. A CSS keyword is a word that has a special meaning to web browser implementers. You might know red is the RGB value (255,0,0), but it's very difficult to remember the values for the 147 colors offered by the CSS 3.0 Specifications. That's why browsers replace the keyword red, for example, with the value (255,0,0) and the same to the other 146 color keywords.

So now that you understand that, you can use keywords as values for properties in CSS. But there's another type of keywords in CSS, the properties. The next selector contains 1 property which is itself a keyword, and its value is a keyword too.

  color: red;

The color property is a keyword that has a special meaning in CSS. The properties font-size, font-family and the rest of the CSS properties are considered to be keywords. We could write the above CSS file as following, without using keywords

  font-family: Tahoma;
  color: rgb(123,104,238);
  font-size: 1em;
  border: 2px solid rgb(173,255,47);
  background-color: rgb(230,230,250);
  font-size: .7em;

So let's talk about these RGB Values.

blog comments powered by Disqus

- CSS Padding Overview
- CSS: Margins Overview
- Top CSS3 Button Tutorials
- More Top CSS3 Tutorials for Animation and Im...
- CSS Mega Menus: Adding Extra Sections
- CSS Mega Menus
- CSS3 Accordian Menu: Horizontally Display Hy...
- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials