This is a Heading

This is a paragraph.

This is a Blue Heading

h2 { color: blue; font-family: verdana; font-size: 300%; } p { color: red; font-family: courier; font-size: 160%; }

This is a heading

This is a paragraph.

p { border: 1px solid powderblue; }

This is a heading

This is a paragraph.

This is a paragraph.

This is a paragraph.

Styling Tables

Firstname Lastname Age
Jill Smith 50
Eve Jackson 94
John Doe 80

Firstname Lastname Age
Jill Smith 50
Eve Jackson 94
John Doe 80

An Unordered HTML List

An Ordered HTML List

  1. Coffee
  2. Tea
  3. Milk

An unordered HTML list

Unordered List with Circle Bullets

Unordered List without Bullets

An ordered HTML list

  1. Coffee
  2. Tea
  3. Milk

Ordered List with Numbers

  1. Coffee
  2. Tea
  3. Milk

Ordered List with Letters

  1. Coffee
  2. Tea
  3. Milk

Ordered List with Lowercase Letters

  1. Coffee
  2. Tea
  3. Milk

Ordered List with Roman Numbers

  1. Coffee
  2. Tea
  3. Milk

Ordered List with Lowercase Roman Numbers

  1. Coffee
  2. Tea
  3. Milk

A Description List

Coffee
- black hot drink
Milk
- white cold drink

A Nested List

List can be nested (lists inside lists):

ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333333; } li { float: left; } li a { display: block; color: white; text-align: center; padding: 16px; text-decoration: none; } li a:hover { background-color: #111111; }

Navigation Menu

In this example, we use CSS to style the list horizontally, to create a navigation menu:

Hello
World

The DIV element is a block element, and will start on a new line.

Hello World

The SPAN element is an inline element, and will not start on a new line.

London

London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.

Standing on the River Thames, London has been a major settlement for two millennia, its history going back to its founding by the Romans, who named it Londinium.

My Important Heading

.city { background-color: red; color: white; padding: 15px; }

The class Attribute

Use CSS to style elements with the class name "city":

London

London is the capital of England.

Paris

Paris is the capital of France.

Tokyo

Tokyo is the capital of Japan.

Using The class Attribute in JavaScript

Click the button, to hide all elements with the class name "city", with JavaScript:

London

London is the capital of England.

Paris

Paris is the capital of France.

Tokyo

Tokyo is the capital of Japan.

.city { background-color: tomato; color: white; padding: 10px; } .main { text-align: center; }

Multiple Classes

All three headers have the class name "city". In addition, London also have the class name "main", which center-aligns the text.

London

Paris

Tokyo

.city { background-color: tomato; color: white; padding: 10px; }

Same Class, Different Tag

Even if the two elements do not have the same tag name, they can have the same class name, and get the same styling:

Paris

Paris is the capital of France.

#myHeader { background-color: lightblue; color: black; padding: 40px; text-align: center; }

The id Attribute

Use CSS to style an element with the id "myHeader":

My Header

/* Style the element with the id "myHeader" */ #myHeader { background-color: lightblue; color: black; padding: 40px; text-align: center; } /* Style all elements with the class name "city" */ .city { background-color: tomato; color: white; padding: 10px; }

Difference Between Class and ID

An HTML page can only have one unique id applied to one specific element, while a class name can be applied to multiple elements.

My Cities

London

London is the capital of England.

Paris

Paris is the capital of France.

Tokyo

Tokyo is the capital of Japan.

Using The id Attribute in JavaScript

JavaScript can access an element with a specified id by using the getElementById() method:

Hello World!

Jump to Chapter 4

Chapter 1

This chapter explains ba bla bla

Chapter 2

This chapter explains ba bla bla

Chapter 3

This chapter explains ba bla bla

Chapter 4

This chapter explains ba bla bla

Chapter 5

This chapter explains ba bla bla

Chapter 6

This chapter explains ba bla bla

Chapter 7

This chapter explains ba bla bla

Chapter 8

This chapter explains ba bla bla

Chapter 9

This chapter explains ba bla bla

Chapter 10

This chapter explains ba bla bla

Chapter 11

This chapter explains ba bla bla

Chapter 12

This chapter explains ba bla bla

Chapter 13

This chapter explains ba bla bla

Chapter 14

This chapter explains ba bla bla

Chapter 15

This chapter explains ba bla bla

Chapter 16

This chapter explains ba bla bla

Chapter 17

This chapter explains ba bla bla

Chapter 18

This chapter explains ba bla bla

Chapter 19

This chapter explains ba bla bla

Chapter 20

This chapter explains ba bla bla

Chapter 21

This chapter explains ba bla bla

Chapter 22

This chapter explains ba bla bla

Chapter 23

This chapter explains ba bla bla

S