![]() ![]() ![]()
![]() ![]() ![]()
|
In Reply to: CSS posted by on March 14, 2012 at 06:25:16:
A CSS declaration always ends with a semicolon, and declaration groups are surrounded by curly brackets:
p {color:redtext-align:center}
========
CSS Comments
Comments are used to explain your code. Comments are ignored by browsers.
A CSS comment begins with /*, and ends with */,
=============
The id and class Selectors
In addition to setting a style for a HTML element, CSS allows you to specify your own selectors called 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 #.
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.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 .
Do NOT start a class name with a number! This is only supported in Internet Explorer
===========
Three Ways to Insert CSS
There are three ways of inserting a style sheet:
#8226External style sheet
#8226Internal style sheet
#8226Inline style
--------------------------------------------------------------------------------
External Style Sheet
An external style sheet is ideal when the style is applied to many pages. Each page must link to the style sheet using the tag. The tag goes inside the head section.
An external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet should be saved with a .css extension.
Do not leave spaces between the property value and the units!it will work in IE, but not in Firefox or Opera.
--------------------------------------------------------------------------------
Internal Style Sheet
An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section of an HTML page, by using the tag,
------
Inline Styles
To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property.
=======
Multiple Style Sheets
For example, an external style sheet has these properties for the h3 selector,
And an internal style sheet has these properties for the h3 selector,
If the page with the internal style sheet also links to the external style sheet the properties for h3 The color is inherited from the external style sheet and the text-alignment and the font-size is replaced by the internal style sheet.
--------------------------------------------------------------------------------