Introduction to CSS

free php tutorials, php classes, php utilities, free tools Introduction
CSS stands for Cascading Style Sheets, it is a simple and powerful language which allows you to specify styles, attributes, and positioning of HTML objects in HTML file. Using Cascading Stylesheets you can control control the layout of your page to look almost exactly as wanted.

Syntax of CSS

CSS contains three major parts:
1)selector
2)property
3) value:

The selector is an HTML element or tag that you define for different styles, the property is the attribute you wish to change, and each property can take a value. The property and value are surrounded by curly braces and separated by a colon:
CSS looks like:

selector
{property:value;}

If the value has multiple words, put quotes around the value
Styles are defined between <style type="text/css"></style> tag.

The syntax is below:

<HTML>
<HEAD>
<style type="text/css">
p{
text-align:center;
font-weight:bold;
color:red
}
body{
background-color:red;
}
</style>  
</HEAD>
<BODY>
<P>This is paragraph</P>
</BODY>
</HTML> 

CSS Comments

Comments are use to ignore any line by the browser. You can insert comments into CSS to explain your code, which can help you when you edit the source code at a later date. A CSS comment begins with "/*", and ends with "*/", like this:

/* This is a comment */
p
{
text-align: center;
/* This is another comment */
color: black;
font-family: arial
}

Bookmark This Page