Discussion Forum

Interative Forum for discussing any query literally to UGC-NET Computer Science, GATE Computer Science and Computer Sciene and Technology in general.

ugc_net image

UGC-NET Computer Science

Correspondence Courses and Test Series to prepare for UGC-NET computer science and applications

GATE image


MCQs, Lecture Notes, Ebooks for GATE preparation

freestuff image
jobs image

Jobs Newsfeed

Timely information of various Recruitments.


Introduction to Stylesheets

CSS was developed by W3C in 1997 and is supported by all the browsers. Style Sheets are a powerful mechanism for adding styles to web documents. Style sheets are also known as CSS. CSS is a document presentation language that helps us to control the layout of HTML documents by attaching styles. Cascading Style Sheets allow you to specify the style of your page elements (font, spacing, margins, etc.) separated from the structure of your document (section headers, body text, links etc). Cascading style sheets enforce standard and uniformity throughout a web site and provide numerous attributes to create dynamic effects. With style sheets, text and images, formatting properties can be predefined in a single list. With CSS, the site maintenance was made a lot easier. The advantages of a style sheet include the ability to make global change to all documents from a single location. Style sheets are said to cascade when they combine to specify the appearance of a page. The CSS document when linked to the web pages of a website provide a consistent look to all the web pages as they take on the characteristics specified in the style at once.

It allows you to specify in one centralized location how you want information for each tag to appear in one or more web pages. E.g. you can specify that you want all H1 headings to appear in one specific font & color etc. In style sheet you enter a tag you want to define characteristic for & then list the characteristic you want the tag to use. A semicolon must separate each characteristic. Style sheet allow you to format & lay out text and images in ways you cannot accomplish with HTML tags. You can create sophisticated web pages that look like a page from a magazine. Style sheets save time as you do not have to type same information in each individual tag. A style sheet makes updation easy. With this you can make changes to your web pages in the centralized location.

This separation of structure from content allows greater manageability and makes changing the style of your document easier. The syntax for making the assignment is simple. The style assigned process is accomplished with the tags. Between the HTML tags, specific style attributes are listed. The tags are written within the … tags.

CSS Syntax

In order to create a style sheet, we have to specify a set of rules knows as CSS rules or styles. These rules are used to control the appearance of various elements that appear in the associated HTML documents. A CSS rule has two main parts: a selector, and one or more declarations:

The selector is normally the HTML element you want to style. Each declaration consists of a property and a value. The property is the style attribute you want to change. Each property has a value. A CSS declaration always ends with a semicolon, and declaration groups are surrounded by curly brackets. If multiple declarations exist then each declaration must be separated by a semicolon (;). The semicolon tells the browser where a declaration ends and other begins.

CSS Example

H1 {color:red; text-align:center;}
To make the CSS more readable, you can put one declaration on each line, like this:

Return To HTML Topics