CSS Introduction - HTML CSS CSS

HTML CSS examples for CSS:Introduction

Defining and Applying a Style

A CSS style has one or more declarations separated by a semi-colon.

Each declaration consists of a CSS property and a value separated by a colon.

A Simple CSS Style

background-color:grey;
color:white

In the code above, the style has two declarations.

The first sets the value grey for the background-color property.

The second sets the value white for the color property.

Applying a Style Using the Style Global Attribute

Demo Code

ResultView the demo in separate window

<!DOCTYPE HTML>
<html>
    <head>
        <title>Example</title>
    </head>
    <body>
        <a href="http://java2s.com" style="background-color:grey; color:white"> website  </a>
        <p>I like <span>CSS</span> and HTML.</p>
        <a href="http://book2s.org">website with no style</a>
    </body>
</html><!-- ww  w . ja va 2s.  c om-->

Related Tutorials