The Internet Classroom
CSS part II
2007/06/25 11:08:28 PDT by kass
Edited at 2007/06/25 11:14:35 PDT
[kass's avatar]

External Stylesheets

<link rel="stylesheet" href="file-name.css" type="text/css" />

Block vs Inline

  • An inline element takes up only as much space on the page as it needs. Examples: a, em, strong, img

  • A block element takes up as much horizontal space as it is given, but only as much vertical space as it needs. Examples: header elements, p, ul/ol, li, dl, table (sorta)

Box Model

  • All block elements follow the box model: 2dboxmodel.png

  • margin -> border -> padding -> content

  • The width and height of an element only defines the content itself (-_-): it does not include padding/margin/border

  • alternatively, if it helps you visualize better... 3d box model

IDs/Classes

  • Will help you create more ways of identifying your code, so that you can apply styles to more unique situations

  • IDs can be accessed by using a pound sign (#) and may only be used ONCE in a document. These are especially good for marking off clear sections in your website, like "navigation" or "content" or "header", etc.

  • Classes can be accessed by using a period and can be used repeatedly in a document.

  • span and div: generic tags that allow for additional IDs/classes

  • Note: Always try to use descendent selectors or IDs before resorting to classes. In many cases, you can access the element you want with the previous two methods. Failure to properly markup your document can result in class abuse.

All TIC materials copyright © 2007 Cynthia Nie and Trevor Ridinger
Powered by Io Community Manager