I AM GREEN

I AM BLUE

I AM RED

this an example of the H1 selector in the HEAD as shown below.
CSS: Cascading Style Sheets.

CSS: Cascading Style Sheets.
Here are 2 examples of where the "STYLE" tag is actually places. The actual top tag should technically be
<STYLE TYPE="text/css"> because there MAY be other types than "text/css" some time in the future but there is not one now and it would probably be the default anyway.

<HTML>
  <TITLE>My home page</TITLE>
  <STYLE>
    <!--
      H1 { color: green }
    -->
  </STYLE>
  <BODY>
    ..
  </BODY> 
</HTML>

---------- the same with "text/css"


<HTML>
  <TITLE> My home page</TITLE>
  <STYLE TYPE="text/css">
    <!--
      H1 { color: green }
    -->
  </STYLE>
  <BODY>
    ..
  </BODY>
</HTML> 

What do we need to know?
  • The Style sheet gives the browser new defaults for things which are not specificly called out for font face, color or whatever and it will do things that are hard to do in other ways.

     

  • Different browsers will show things APROXAMATELY the same.

     

  • Style sheets are locates in the "HEAD" generaly just before BODY
    to prevent other "HEAD" tags from being styleized

     

  • A CSS style sheet begins with "<STYLE TYPE="text/css">" and ends with " </STYLE>."

      OK so "text/css" is not technically necessary but good to do anyway.

     

  • A CSS comment begins with "/*" and ends with "*/." and can not be nested.

     

  • A HTML comment begins with "<--" and ends with "-->."

     

  • General form is "tag we are talking about" { "which property" : "what we want it to be" }

     

  • example H1 { color: green }
    The <HI> tag
    we want to do something with the color
    what we want is to make them green

     

  • So now the more formal names:
    Style rules are formed as follows:
    selector { property: value }

     

  • So the selector can be most HTML tags:
    also called HTML elements
    for example: BODY, P, EM, H1, H2

     

  • The { property: value } together are called the "style declaration"
    or just "declaration" for short
    and they are kind of a matched set.

     

  • so here is a list of Selectors
  • so here is a list of CSS Properties
  • so here is a list of CSS Values
  • so here is a list of CSS Specal Cases
  • Multiple style declarations for a single selector may be separated by a semicolon:
    selector { property1: value1; property2: value2 }

     

  •  

A list of Selectors that I know about.

ADDRESS, B, BLOCKQUOTE, BODY, BR, CITE, CODE, DD, DIR, DIV, DL DT, EM, FORM, H1, H2, H3, H4, H5, H6, HR, I, IMG, KBD, LI MENU, OL, P, PRE, SAMP, SPAN STRONG, TT, UL, VAR,
A list of CSS Properities that I know about.

CSS Properties
There are only so many properties and each can have one or more values.

Font Properties

Font Family {font-family: Courier, monospace } {font-family: Verdana,Times } {font-family: Arial, Helvetica }. (Font names with whitespace are quoted like: "new century schoolbook", fonts seperated by commas are altinates There are two types of list values and the browser trys to pick one the viewer has: like "gill" and "helvetica"
like (serif e.g. Times) (sans-serif e.g. Helvetica) (cursive e.g. Zapf-Chancery) (fantasy e.g. Western) (monospace e.g. Courier) )

Font Style { font-style: italic }, { font-style: 'oblique }(often slanted) and normal

Font Variant {font-variant: normal } and {font-variant: small-caps }

Font Weight {font-weight: normal }. {font-weight: bold }. ( Value: normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 with higher numbers darker)
Font Size {font-size: 70% }, {font-size: 12pt } {font-size: 120% } {font-size: large}, {font-size: small } or {font-size: x-small }.(also xx-small, xx-large, 1.5em

Font SPECIAL GENERIC CASE
{font: bold italic large Palatino, serif } or
{ font: 12pt/14pt sans-serif }

('font' is a shorthand for setting
The trick here is that they are set in this order [if used] with the same notation as would have been used but with out each individual property
'font-style'
'font-variant'
'font-weight'
'font-size',
'line-height' and
'font-family'[comma seperated]
at the same place in the style sheet.)


Color and Background Properties
NOTE: Color useing in the form "Red,Red,Green,Green,Blue,Blue" #rrggbb for short like this #00FFFF always works There are only so many "named" colors like {color: blue} and only the more common ones always work.

Color {color: #00FFFF} or {color: blue} Text, area or whatever will be this color.

Background Color {background-color: blue} Text, area or whatever will be blue. #0000FF also works

Background Image {background-image: url(picture.gif)} Background will have this picture as a background.

Background Repeat {background-repeat: no-repeat } (Image is not repeated)
{background-repeat: repeat } (Image is repeated both horozontaly and vertically the default)
The X and Y refer to X,Y Coordinates
{background-repeat: repeat-y } makes the image repeat to create a single band of images from one side to the other.
{background-repeat: repeat-x } makes the image repeat to create a single collumn of images from top to the bottom.


Background Attachment { background-attachment: fixed } (It is fixed with regard to the webpage)
{ background-attachment: scroll } (Makes it to scrolls along with the content. )


Background Position Percentage values are allowed on (not yet known how it works but it uses percentage )

Background { background: red },{ background: url(marble.gif)}
(A general form, other specializes ones also exist (i.e., 'background-color', 'background-image', 'background-repeat', 'background-attachment' and 'background-position')


Text Properties

Word Spacing { word-spacing: normal } { word-spacing: 1em } (The length unit indicates an addition to the default space between words.)

Letter Spacing {letter-spacing: normal } {letter-spacing: 0.1em } (The length unit indicates an addition to the default space between characters.)

Text Decoration { text-decoration: none } {text-decoration: underline} {text-decoration: overline} {text-decoration: line-through} {text-decoration: blink } (Text will be underlined/overlined/line-theough or blink. default is none.)

Vertical Alignment {vertical-align: sub} (Value: baseline=(Initial default) | sub | super | top | text-top | middle | bottom | text-bottom | percentage ) .

Text Transformation {text-transform: none} {text-transform: lowercase} { text-transform: uppercase } { text-transform: capitalize } Text will be rendered as lowercase, capitalize or uppercase.

Text Alignment {text-align: center} ( Text will left | right | center | justify aligned.)

Text Indentation {text-indent: 1em} ( Text will be indented 1 em.) the indentation that appears before the first formatted line. ( may be negative length | percentage)

Line Height { line-height: 200% } Value: normal | number (1.2 if font-size is used) | length 1.2em | percentage (120% if font-size is used)


Table Properties

Margin (The same all around){ margin: 2em} or { margin: 7%}

Right Margin or Left Margin { margin-left: 10%; margin-right: 10% }

Top Margin or Bottom Margin { margin-top: 8em; margin-bottom: 3em }



Padding ( space between the border and it's content in length or percentage)
{padding: 2px} Padding will be 2 pixels on each side.
In an other case: {padding: 8px 3px 6px 4px}
(Remember: top center, than clockwise)
Bottom padding will be 6 Top padding will be 8 pixels; Right padding will be 3 pixels. bottom padding will be 6 pixels; left padding will be 4 pixels.

Top Padding { padding-top: 0.3em }
Right Padding { padding-right: 10px }
Bottom Padding { padding-bottom: 2em }
Left Padding { padding-left: 20% }


Border (A generic term) like:
{ border: solid 0.5em } or { border: solid thick red }.


Border Width (Value: thin | medium | thick | length)
Top Border Width or Right Border Width or Bottom Border Width or Left Border Width
{border-top-width: medium; border-right-width: thick; border-bottom-width: thin; border-left-width: 10px;}.

Border Color {border-color: black; } .

Border Style {border-style: dotted} .
(Values: none | dotted | dashed | solid | double | groove | ridge | inset | outset)

Top Border or Right Border or Bottom Border or Left Border
(Style or color)

Width (Values: length | percentage | auto )
{ width: 100px }.

Height (Values: length | auto )
{ height: 100px } .

Float { float: left }, { float: right }, { float: none }, (With a value of 'left' the element [normally an image] will be moved to the left and the text will wrap on the right side of the element.)

Clear { clear: none }, { clear: left }, { clear: right }, { clear: both } (Defines where floating elements are NOT allowed. The area is 'Clear') .

Classification Properties

Display (describes how/if an element is displayed on the a computer display etc.). (Values: block | inline | list-item | none)
{ display: block }(block - opens a new box close to adjacent boxes )
{ display: inline }(inline - box on the same line)
{ display: list-item } (inline applies to ' margin, border and padding but not line breaks. )
{ display: none } (none is none)

Whitespace { white-space: normal } (normal is none)
{ white-space: pre } (pre is )
{ white-space: nowrap } (nowrap is like preformated except whitespase is not wraped to the next line)

List-item elements are a lot like HTML

List Style (Generric) {list-style: disc } (Values: [disc, circle, square, decimal, lower-roman, upper-roman, lower-alpha, upper-alpha, none] )

List Style Type {list-style-type: circle} (disc, circle, square, decimal, lower-roman, upper-roman, lower-alpha, upper-alpha, none )

List Style Image { list-style: url(http://www.waltm.net/smile.gif) disc } (disc will be the altinate)

List Style Position {list-style-position: inside } or {list-style-position: outside}


Measurements

Length Units By percent "%", pixels "px" or "em" (relative to the size of font in that area, so a bigger font will have a bigger amount for the same "em")

Percentage Units Percentages are generally for things like FONT, more or less times their normal size. For tables, margins and such, it is usually a percent of the whole screen.

Color Units The known named ones like "blue" and Hexedecmial form of "#rrggbb"

URLs Like picture.gif, mystyle.css (traditional extention for external style sheets), pix.jpg

A list of CSS Properities that I know about.


GENERAL FORM (there are shortcuts)
<STYLE TYPE="text/css"> 
    <!--
Selector (s) {Property: Value 
; Property: Value ...
 }
    -->
  </STYLE>

Colors can usually be SOME names like red, blue but almost always by HEX 
like #FF09A3 

Sizes MAY be by "em", "%", (in the case of font "pt")


<STYLE TYPE="text/css">
    <!--
 p 
{font-family: Helvetica, Geneva; /* font-family: Arial, serif;
The same idea as in "face" for the FONT tag  */
font-weight: bold; /* font-weight: normal; */
font-size: 12pt;  /* Like type setters points - 72 = an inch 
on the screen it will be sort of like that */
font-style: italic; /* font-style: italized; */
font-variant: normal;
line-height: normal; 
}
    -->
  </STYLE>


Margins
<STYLE TYPE="text/css">
    <!--
BLOCKQUOTE {
 margin-top: 1em;
  margin-right: 0.5em;
  margin-bottom: 2em;
  margin-left: 0.4em;
}
    -->
  </STYLE>
The "em" unit is on a scale relative to the font size. And "1em" is a 
margins as high as the font size that us used there

SHORTCUT:
BLOCKQUOTE { 
  margin: 1em 0.5em 1em 0.4em;
}
It goes from the top, than clockwise.
  margin: 1em 0.5em 2em 0.4em;
          |    |    |    |
          |    |    |    |==> (your) Left Margin
          |    |    |
          |    |    |==> Bottom Margin
          |    |
          |    |==> (your) Right Margin
          |
          |==> Top Margin

  padding: 0.5em; /* This is the SAME amount on all sides  */

<STYLE TYPE="text/css">
    <!--

    -->
  </STYLE>

Some CSS Special Cases that I know about.

CSS SPECIAL CASES

! important Rules with ! important will win out over contradictory styles of otherwise equal weight.
like { font-size: 12pt ! important; font-style: italic }

Linking
the "Style sheet" can be in a seperate file and called out. So it acts as if it was actualy written in the <HEAD>. So it can be written once and applied to lots of web pages.

To use the same styles for several Web pages you call in
a style sheet (which you wrote) and add a few special ones

<STYLE TYPE="text/css">
    <!--
      <link rel="stylesheet" href="style.css">
      I { color: green }
      U { color: red ; font-size: 120% }
      H1 { color: green }
      H2 { color: blue }
      H3 { color: red }
      LI { color: red }
      PRE { color: blue }
    -->;
  </STYLE>


ID
This is where a particular "Selector" "Style" applies to only those IDentafied as the ones it should apply to. Also a "Style" to be used by ANY selector which is identified later. The pound sign, "#" is the key to the style you call out, and Identifying what "Selector" (tag) uses it.
OK, say in the head you have:
<STYLE TYPE="text/css">
    <!--
      U#see1 { color: red ; font-size: 120% }
      #frog { color: green }
      ... (other stuff here)
    -->;
  </STYLE>

Than in the body you have <U ID=see1>Big Underlined text</U>. and this would only apply to underlined text. The next one applies to ANY tag (AKA Selector) Say <I ID=frog>Green italized text</I> or <B ID=frog>Green bold text</B>
Class
Is like ID but it uses a dot (period) in place of the pound sign.
<STYLE TYPE="text/css">
    <!--
      .warning { font-weight: bolder; color: red; background: white }
      P.warning { font-weight: bolder; color: red; background: white }
      ... (other stuff here)
    -->;
  </STYLE>
Than in the body you have: <B CLASS=warning> Notice: Do NOT piss on the spark plug when the engine is running.</B>
Inherentance
Simple means anything within the tags named out, also gets the "value" unless specificly called out different.
For example:
Between <TABLE> and </TABLE> Things like <TD> and </TD> get the style that was applied to <TABLE>.

My HomePage

Last Modified on: