Basic HTML & CSS

Junghoo Cho

cho@cs.ucla.edu

From Text to Structured Document

HTML (HyperText Markup Language)

HTML History (1)

HTML History (2)

HTML5

HTML5: Bare Minimum

<!DOCTYPE html>
<html>
<head><title>...</title></head>
<body>...</body>
</html>

HTML Element

HTML Attributes

HTML Tags are for Structure

Formatting vs Structure Tags

Special Characters

Embedding Rich Objects (1)

Embedding Rich Objects (2)

Embedding Rich Objects (3)

More in HTML5

XHTML

CSS (Cascading Style Sheet)

CSS Rules

Adding CSS Rules to Page

More CSS selectors (1)

[src] { /* has attribute named "src" */
    color: red;  
}
[target="_blank"] { /* has attribute "target" with value "_blank" */
    color: blue; 
}
div, p { /* multiple selectors separated by commas */
    background-color: grey;
}
div p { /* p is a descendent of div */
    background-color: yellow;
}
div > p { /* p is a direct child of div */
    background-color: green;
}

More CSS selectors (2)

p.class1.class2 { /* p belonging to both class1 and class2 */
    background-color: yellow;
}
div + p { /* p is an immediately adjacent sibling of div */
    background-color: blue;
}
div ~ p { /* p is any sibling of div */
    background-color: red;
}
:hover { /* : "pseudo class" selector */
    color: #0000ff;
}
::first-letter { /* :: "pseudo element" selector */
    font-size: 2em;
}

Inheritance

Cascading Rule

HTML Validator

Retrieving Static Content

Static Web Site

URL (Uniform Resource Locator)

What We Learned

References