18
CSS

Look especially at › File Tips and Shortcuts › Student video

Embed Size (px)

Citation preview

Page 1: Look especially at › File Tips and Shortcuts › Student video

CSS

Page 2: Look especially at › File Tips and Shortcuts › Student video

New Resources Posted

Look especially at › File Tips and Shortcuts› Student video

Page 3: Look especially at › File Tips and Shortcuts › Student video

Special symbols in HTML < and > are special symbols with special

meaningsHow would you display A < B ?Suggestions?

&lt; for < and &gt; for >& is an escape symbol, handled specially.Always ends with ;

Means that you need a special way to display

“&” too: &amp;

Good list at http://www.utexas.edu/learn/html/spchar.html

Page 4: Look especially at › File Tips and Shortcuts › Student video

Web Instructions: Three Legs

HTML

Content

CSS

Presentation

JavaScript

Behavior

Page 5: Look especially at › File Tips and Shortcuts › Student video

CSS...CSS is for giving style to your contentHTML: contentCSS: styleCSS Zen Garden

Page 6: Look especially at › File Tips and Shortcuts › Student video

What can you change?

Font: size, color, style› More on color next week› For now, by name

Background Border

› Must have size color and style Position: margins, centering Size

Page 7: Look especially at › File Tips and Shortcuts › Student video

Syntax (how it looks)

Selector specifies the HTML element to styleDeclaration:

always contains a property & valueends with a semicolon

Property: style element you want to change Value: what you are changing the property to

Page 8: Look especially at › File Tips and Shortcuts › Student video

Formatting your CSS

Formatting Practices:some flexibility, but you must be consistent.always comment unclear code!

/* someCommentHere */curly bracestab alignment

Bad practices:declarations on the same line as braces or selectormultiple declarations on the same lineleaving off the last semi-colon

Page 9: Look especially at › File Tips and Shortcuts › Student video

Commonly Used Tags & Properties

full reference sheet

Page 10: Look especially at › File Tips and Shortcuts › Student video

Font Families

Preferable to use: universality Multiple fonts: use first available

Page 11: Look especially at › File Tips and Shortcuts › Student video

Defining size

pt refers to printer’s font measurement

px refers to pixels

em is a relative measure› 1 em = base size (defined in body or

default)› Great for changing all at once

Page 12: Look especially at › File Tips and Shortcuts › Student video

Page Structure

Page 13: Look especially at › File Tips and Shortcuts › Student video

General Page Structure<!DOCTYPE html>

<html><head> <! ---defining character necessary for validation --- > <meta charset="UTF-8"> <! --- what shows up on the tab --- >

<title>Put your title here</title></head><body>

<! --- the “good stuff” i--- > What will appear on the page

</body>

</html>

Page 14: Look especially at › File Tips and Shortcuts › Student video

The Body

Every page needs› Header (DIFFERENT THAN head)› Content› Footer

Minimal content› Header: title› Footer: who wrote it and when

Page 15: Look especially at › File Tips and Shortcuts › Student video

Dividing Up the BodyBasic model:

<header>…</header>Use for main title

<main> … </main> Use for the main content

<footer> … </footer>Use for accreditations and citations

Each section can be formatted independently (soon)

Page 16: Look especially at › File Tips and Shortcuts › Student video

Adding CSS to your HTML

The best (only way for this class!) way to insert CSS to your HTML is by using an External Style Sheet

Define all your styles in one placeEasily change the look of your siteUse the following <link> tag within the <head> tag

Save your external style sheet as a .css file.

<link href=“mystyle.css” rel=stylesheet type=“text/css”>

Page 17: Look especially at › File Tips and Shortcuts › Student video

Folder Structure

Page 18: Look especially at › File Tips and Shortcuts › Student video

One folder per assignment

Contains all needed pages› HTML› CSS› (more to follow)

Main (first) page called index.html Can view the page with the folder

name unc.edu/~pozefsky/foldername