CSS Introduction

What is CSS?

CSS stands for Cascading Style Sheets. It defines how to display HTML elements.

The following HTML code includes CSS for styling.


<!DOCTYPE HTML> 
<html> 
    <head> 
        <style> 
        a { <!--   w w  w  . j  a  va 2s  .co  m-->
            background-color:grey; 
            color:white 
        } 
        </style> 
    </head> 
    <body> 
        <a href="http://java2s.com">Visit the website</a> 
    </body> 
</html>

Click to view the demo

The code above set the background color and foreground color.

Styles are normally saved in external .css files.

The code above generates the following result.

CSS Introduction