CSS STYLE SHEETS

Boy, did this scare me at first. CSS — Cascading Style Sheets. Got to be a name one of the ‘techies’ thought up. Don’t you think?

Sounds like a cascading waterfall that builds up speed and power the further into it you go until… whoosh you’re buried in a 100-foot waterfall!

But don’t let it fool you. CSS makes your job easier. Trust me, it really does. Let’s add some style right now, OK?

(Just in case you want to READ about CSS
here’s the developers reference.)

When you read a book you’ll notice that the first line of a paragraph is usually indented. Until CSS came along, there was no simple way to do this on web pages. 

If you’d like to indent the first line of your paragraphs, just paste the following into the HEAD section of your page or add the middle line of code to your linked stylesheets: 

<style type=”text/css”> 
<!– 

p { text-indent: 2em;} 

–> 
</style> 

 

HIGHLIGHTING

With CSS you can highlight text on a page, making it look like you ran a yellow highlight marker over it. This is great for emphasizing important words or points. 

Just add this code to the HEAD section of your HTML page: 

<style type=”text/css”> 
<!– 

.HL {background: #ffff99; 
color: #000000;} 

–> 
</style> 

What you’ve done is create a CSS class, and now the table is set. To use it to highlight a passage, you could write: 

<font>this is highlighted</font>

The words “this is highlighted” will have a yellow background with black text. Of course, you can change those colors to anything you want by modifying the colors in the CSS code. 

Let’s not stop there. OK? What about if we wanted to highlight an entire paragraph? If you don’t like messing with tables, try this style tag: 

<P style=”background-color: FEE333″;> 

All of the text in the above paragraph will be highlighted in yellow-orange. To change that color, just substitute any other hex code or use a color name. 

This CSS tag works in both Netscape and Internet Explorer. 

SPACING FOR LINES & PARAGRAPHS

Sometimes the designer (YOU) doesn’t want so much space between paragraphs. (Like when using bullets or such) You can control the space between paragraphs — and lines — like this:

You can set the line height for paragraphs with a little CSS in the HEAD section of your HTML document, like this: 

<style type=”text/css”> 
<!– 
P {line-height : 12px;} 
–> 
</style> 

Just change the “12px” to however many pixels you need it to be. The comment tags should be included to prevent crotchety older browsers from displaying the code. 

You can set the line height for paragraphs with embedded style sheets — CSS in the HEAD section of your HTML document — like this: 

<style type=”text/css”> 
<!– 
p {line-height : 20px;} 
–> 
</style> 

Just change the “20” in 20px (pixels) to the number you need. 

You can also place the CSS code right in your HTML tag, as an inline style. 

<p style=”line-height: 20px;”> 

Both methods accomplish the same thing. The advantage of embedding them in the HEAD section is that the line height will be applied every time you use a <p> tag. With the inline style, you have to insert the CSS code into each paragraph 

Now let’s see what it looks like, both in CODE and diplayed in the browser. 

 

CSS UNDERLINE/OVERLINE LINKS

There are some very cool ways to handle links in your page. Here’s one that uses the CSS to make your links look different. Just try underlining AND overlining them, framing them between horizontal lines. Just add: 

<style type=”text/css”> 
<!– 
A:hover {text-decoration:overline underline} 
–> 
</style> 

to the HEAD section of your page. The underline and overline will display whenever a visitor moves the cursor over the links. 

A variation: If you remove the word “underline” from the above code, the link will be underlined (with no overline) at rest, and overlined (with no underline) when a visitor’s cursor is hovering over it. 

<style type=”text/css”> 

<!–
a:hover{color:ff0080; background-color:ffff00;}
–>
</style> 

 

FORM ELEMENTS

There is a lot you can do with CSS. Here’s an example of CSS working with form elements. Form elements can be a bit boring…so we’re going to liven things up a bit.

Let’s first start with a simple head tag that will color all the elements in a text field box.

 

BUTTONS

Now what about those awful looking buttons? First let’s change the shape… 

<input type=”reset” value=”Reset” style=”width: 80px;”> 

Just reset the pixel number to whatever you like as long as it’s larger than the text.

We can take it a step further in IE and add effects to the boxes:

Cut and Paste this into the <Head>

<STYLE>
.bigChange {color:blue; font-weight:bolder; font-size:175%;
letter-spacing:4px; text-transform: uppercase; background:yellow}
.start {color:yellow; background:navy}
</STYLE>


function highlightButton(s) {
if (“INPUT”==event.srcElement.tagName)
event.srcElement.className=s
}

And this into the body:

<FORM NAME=highlight onmouseover=”highlightButton(‘start’)”
onmouseout=”highlightButton(”)”>
<input type=”button” Value=”Pass your mouse over me”>
</FORM>

Now on to the final CSS trick. Are you still with me? Good.

** CSS LINK MENU **

We’re going to create a menu using CSS only. Awesome stuff here. I won’t take up space here to list the code. Just look at it in the popup window and copy the code from ‘view source’.

Let’s move on to more dynamic uses of code. Are you game?

 

Advertisements

Cascading Style Sheet Chart

Cascading Style Sheet Chart
A cascading style sheet (CSS) allows you to control the appearance of your fonts, links, tables and more. This sheet provides a listing of essential properties and values.
  1. Background css – Page1
  2. Border – Page1
  3. Classification – Page2
  4. Dimension – Page2
  5. Font – Page2
  6. List – Page2
  7. Margin – Page2
  8. Padding – Page3
  9. Positioning – Page3
  10. Text – Page3

Background

Property Values Description NS IE
background background-color
background-image
background-repeat background-attachment background-position
Sets all background properties in one statement 4.0 4.0
background-attachment scroll
fixed
Sets whether a background image is fixed or scrolls with the rest of the page 4.0
background-color color-rgb
color-hex
color-name
transparent
Sets the background color of an element 4.0 4.0
background-image url
none
Sets an image as the background 4.0 4.0
background-position top left
top center
top right
center left
center center
center right
bottom left
bottom center
bottom right
x-% y-%
x-pos y-pos
Sets the starting position of a background image 4.0
background-repeat repeat
repeat-x
repeat-y
no-repeat
Sets if/how a background image will be repeated 4.0 4.0

Border

Property Values Description NS IE
border border-width
border-style
border-color
Sets all of the properties for the four borders in one statement 4.0 4.0
border-bottom border-bottom-width
border-style
border-color
Sets all of the properties for the bottom border in one statement 4.0
border-bottom-width thin
medium
thick
length
Sets the width of the bottom border 4.0 4.0
border-color color Sets the color of the four borders, can have from one to four colors 4.0
border-left border-left-width
border-style
border-color
Sets all of the properties for the left border in one statement 4.0
border-left-width thin
medium
thick
length
Sets the width of the left border 4.0 4.0
border-right border-right-width
border-style
border-color
Sets all of the properties for the right border in one statement 4.0
border-right-width thin
medium
thick
length
Sets the width of the right border 4.0 4.0
border-style none
dotted
dashed
solid
double
groove
ridge
inset
outset
Sets the style of the four borders, can have from one to four styles 4.0
border-top border-top-width
border-style
border-color
Sets all of the properties for the top border in one statement 4.0
border-top-width thin
medium
thick
length
Sets the width of the top border 4.0 4.0
border-width thin
medium
thick
length
Sets the width of the four borders in one statement, can have from one to four values 4.0 4.0
Classification

Property Values Description NS IE
clear left
right
both
none
Sets the sides of an element where other floating elements are not allowed 4.0 4.0
display none
block
inline
list-item
Sets how/if an element is displayed 4.0 4.0
float left
right
none
Sets where an image or a text will appear in another element 4.0 4.0
position static
relative
absolute
fixed
Places an element in a static, relative, absolute or fixed position 4.0 4.0
visibility visible
hidden
collapse
Sets if an element should be visible or invisible 4.0

Dimension

Property Values Description NS IE
height auto
length
Sets the height of an element 4.0
line-height normal
number
length
%
Sets the distance between lines 4.0 4.0
width auto
%
length
Sets the width of an element 4.0

Font

Property Values Description NS IE
font font-style
font-variant
font-weight
font-size/line-height
font-family
Sets all of the properties for a font in one statement 4.0 4.0
font-family family-name
generic-family
A prioritized list of font family names and/or generic family names for an element 4.0 4.0
font-size xx-small
x-small
small
medium
large
x-large
xx-large
smaller
larger
length
%
Sets the size of a font 4.0 4.0
font-style normal
italic
oblique
Sets the font-style 4.0 4.0
font-variant normal
small-caps
Sets the font-variant 4.0
font-weight normal
bold
bolder
lighter
100
200
300
400
500
600
700
800
900
Sets the weight of a font 4.0 4.0

List

Property Values Description NS IE
list-style list-style-type
list-style-position
list-style-image
Sets all of the properties for a list in one statement 4.0
list-style-image none
url
Sets an image as the list-item marker 4.0
list-style-position inside
outside
Sets were the list-item marker is placed in the list 4.0
list-style-type none
disc
circle
square
decimal
lower-roman
upper-roman
lower-alpha
upper-alpha
Sets the type of the list-item marker 4.0 4.0

Margin

Property Values Description NS IE
margin margin-top
margin-right
margin-bottom
margin-left
Sets the margin properties in one statement 4.0 4.0
margin-bottom auto
length
%
Sets the bottom margin of an element 4.0 4.0
margin-left auto
length
%
Sets the left margin of an element 4.0 4.0
margin-right auto
length
%
Sets the right margin of an element 4.0 4.0
margin-top auto
length
%
Sets the top margin of an element 4.0 4.0

Works With Internet Explorer 4.0+
Netscape 4.0+

Padding

Property Values Description NS IE
padding padding-top
padding-right
padding-bottom
padding-left
Sets the padding properties in one statement 4.0 4.0
padding-bottom length
%
Sets the bottom padding of an element 4.0 4.0
padding-left length
%
Sets the left padding of an element 4.0 4.0
padding-right length
%
Sets the right padding of an element 4.0
padding-top length
%
Sets the top padding of an element 4.0 4.0

Positioning

Property Values Description NS IE
bottom auto
%
length
Sets where the bottom of an element should be positioned 5.0
clip shape
auto
Sets the shape of an element. The element is clipped into this shape, and displayed 4.0
left auto
%
length
Sets where the left side of an element should be positioned 4.0 4.0
overflow visible
hidden
scroll
auto
Sets what happens if the content of an element does not fit into its area 4.0
right auto
%
length
Sets where the right side of an element should be positioned 5.0
top auto
%
length
Sets where the top of an element should be positioned 4.0 4.0
vertical-align baseline
sub
super
top
text-top
middle
bottom
text-bottom
%
Aligns an element vertically 4.0 4.0
z-index auto
number
Sets the stack order of an element 4.0

Text

Property Values Description NS IE
color color Sets the color of a text 4.0 4.0
letter-spacing normal
length
Increases or decreases the space between characters 4.0
text-align left
right
center
justify
Aligns the text in an element 4.0 4.0
text-decoration none
underline
overline
line-through
blink
Adds decoration to text 4.0 4.0
text-indent length
%
Indents the first line of text in an element 4.0 4.0
text-transform none
capitalize
uppercase
lowercase
Controls the letters in an element 4.0 4.0
white-space normal
pre
nowrap
Sets how white space inside an element is handled 4.0
word-spacing normal
length
Increases or decreases the space between words

HTML5 – a few bullet points

HTML has been on a wild ride. Sure, HTML started as a mere markup language, but more recently HTML’s put on some major muscle. Now we’ve got a language tuned for building true web applications with local storage, 2D drawing, offline support, sockets and threads, and more.

If you’ve never had exposure to HTML5 before, that’s okay, but you should have worked with HTML, and there are some basics you should know about like elements, tags, attributes, nesting, the difference between semantic markup and adding style, and so on.
If you aren’t familiar with all these, we’re going to make a small suggestion (and a shameless plug): there’s a book called Head First HTML
with CSS & XHTML, and you should read it. And if you’re somewhat familar with markup languages, you might want to skim it or use it as a reference while coding HTML5.

html5_1920x1200