Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CSS Cascading Style Sheets, Study notes of Web Design and Development

css - css - css - css

Typology: Study notes

2012/2013

Uploaded on 01/29/2013

bunkeraditya
bunkeraditya 🇮🇳

4

(2)

8 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSS defines HOW HTML elements are to be displayed.
Styles are normally saved in external .css files.
External style sheets enable you to change the appearance and layout of all the pages in a
Web site, just by editing one single file!
-------------------------------------------------- CSS Syntax
--------------------------------------------------
A CSS rule has two main parts: a selector, and one or more declarations:
e.g. -- h1 {color:blue ; font-size:12px ;}
p {color:red;text-align:center;}
To make the CSS more readable, you can put one declaration on each line, like this:
Example
p
{
color:red;
text-align:center;
}
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...
********** CSS Comments **********
Comments are used to explain your code, and may help you when you edit the source code at
a later date.
Comments are ignored by browsers.
A CSS comment begins with "/*", and ends with "*/"
-------------------------------------------------- CSS Id and Class
--------------------------------------------------
********** The id Selector **********
The id selector is used to specify a style for a single, unique element.
The id selector uses the id attribute of the HTML element, and is defined with a "#".
The style rule below will be applied to the element with id="para1":
Example :
pf3
pf4

Partial preview of the text

Download CSS Cascading Style Sheets and more Study notes Web Design and Development in PDF only on Docsity!

CSS defines HOW HTML elements are to be displayed. Styles are normally saved in external .css files. External style sheets enable you to change the appearance and layout of all the pages in a Web site, just by editing one single file!

-------------------------------------------------- CSS Syntax

A CSS rule has two main parts: a selector, and one or more declarations:

e.g. -- h1 {color:blue ; font-size:12px ;} p {color:red;text-align:center;}

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

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...

********** CSS Comments **********

Comments are used to explain your code, and may help you when you edit the source code at a later date. Comments are ignored by browsers.

A CSS comment begins with "/", and ends with "/"

-------------------------------------------------- CSS Id and Class

********** The id Selector **********

The id selector is used to specify a style for a single, unique element. The id selector uses the id attribute of the HTML element, and is defined with a "#". The style rule below will be applied to the element with id="para1":

Example :

Hello World!

This paragraph is not affected by the style.

Do NOT start an ID name with a number! It will not work in Mozilla/Firefox.

********** The class Selector **********

The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements. This allows you to set a particular style for many HTML elements with the same class. The class selector uses the HTML class attribute, and is defined with a "."

Center-aligned heading

Center-aligned paragraph.

You can also specify that only specific HTML elements should be affected by a class. In the example below, all p elements with class="center" will be center-aligned: Example p.center {text-align:center;}

********** Multiple Styles Will Cascade into One **********

Styles can be specified:

inside an HTML element inside the head section of an HTML page in an external CSS file

Even multiple external style sheets can be referenced inside a single HTML document.

Cascading order : What style will be used when there is more than one style specified for an HTML element?

Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the following rules, where number four has the highest priority:

Browser default External style sheet Internal style sheet (in the head section) Inline style (inside an HTML element)

So, an inline style (inside an HTML element) has the highest priority, which means that it will override a style defined inside the tag, or in an external style sheet, or in a browser (a default value).

If the link to the external style sheet is placed after the internal style sheet in HTML , t he external style sheet will override the internal style sheet!