RULES
A style sheet can be broken down into progressively smaller bits. From large to small, those pieces are:
➤ Style sheet
➤ Rule
➤ Selector
➤ Declaration
➤ Property
➤ Value
SELECTORS
In CSS, a selector is the HTML element or elements to which a CSS rule is applied. Put simply, the selector tells the browser what to style
Grouping Selectors
When more than one selector appears in the same rule, they are said to be grouped
DECLARATIONS
Declarations are enclosed within curly braces ({}) to separate them from selectors.
A declaration is composed of a property name, a colon, and, depending on the property, one or more values.
A Declaration is property : value(s)
body <----------------- selector
{
width: 650px; <---------------- declaration
margin: 0 auto;
background: #000;
color: #FFF;
font: 12px sans-serif;
}
Values in a declaration
Keyword: A keyword value is a named value
Eg. red, green, and blue, bold, left, auto etc.
Strings:
One use of strings in CSS is to specify a font that contains spaces in its name
font-family: ‘Times New Roman’, Times, serif;
Length and Measurement
There are two kinds of lengths used in CSS:
absolute
UNIT ABBREVIATION DESCRIPTION
in Inches
cm Centimeters
mm Millimeters
pt Points, 1 point is equal to 1/72nd of an inch
pc Picas, 1 pica is equal to 12 points
relative
UNIT ABBREVIATION DESCRIPTION
em Length relevant to the nearest font size.
ex The x-height of the relevant font (height of the letter x).
px Pixels, relative to the viewing device, for example, a computer monitor.
% Percentage measurement; how percentage length is calculated depends on what property it is being applied to.
Including CSS in a Document
using embedded style sheets, which are included between <style> and </style> tags directly in an HTML document
<style type=”text/css”>
body {
font: 12px sans-serif;
}
</ style >
CSS can be included in its own document and linked to an HTML document
<link rel=”stylesheet” type=”text/css” href=”example_1-1.css”>
CSS can be imported from within either an embedded or linked style sheet by using an @import rule.
<style type=”text/css”>
@import url(example_1-1.css);
</ style >
CSS declarations can be applied directly to an element in an HTML document by using inline styles with the style attribute
<body style=”font: 12px sans-serif;”>
CSS
Friday, August 29, 2014
Introduction
Cascading Style Sheets (CSS) is a language designed for describing the appearance of documents written in a markup language such as HTML
Advantages of CSS
You can break down browsers into groups based on the engine that they use for rendering pages.
Webkit: Apple Safari and Google Chrome
Trident: Internet Explorer
Gecko: Firefox
Presto: Opera
Advantages of CSS
- The presentation of an entire website can be centralized to one or a handful of documents
- more than one design of a website to be presented at the same time. The user can simply select the look and feel that he or she likes most
- Style sheets allow content to be optimized for more than one type of device.
- Style sheets download much more quickly because web documents using CSS commonly consume less bandwidth. Browsers also use a feature called caching,
- Users of a website can compose style sheets of their own, a feature that makes websites more accessible
You can break down browsers into groups based on the engine that they use for rendering pages.
Webkit: Apple Safari and Google Chrome
Trident: Internet Explorer
Gecko: Firefox
Presto: Opera
Subscribe to:
Posts (Atom)