My first css example

This is a paragraph

Hello world!

Every element on the page will be affected by the style.

Me too!

And me!

Hello World!

Smaller heading!

This is a paragraph.

Transparent Boxes 2

Result with opacity:

10% opacity

30% opacity

60% opacity

opacity 1

Result with rgba():

10% opacity

30% opacity

60% opacity

default

Notice how the text gets transparent as well as the background color when using the opacity property.

CSS background-color example!

This is a text inside a div element.

This paragraph has its own background color.

We are still in the div element.

The border-style Property

This property specifies what kind of border to display:

A dotted border.

A dashed border.

A solid border.

A double border.

A groove border.

A ridge border.

An inset border.

An outset border.

No border.

A mixed border.

The border-width Property

This property specifies the width of the four borders:

Some text.

Some text.

Some text.

Some text.

Some text.

Some text.

Note: The "border-width" property does not work if it is used alone. Always specify the "border-style" property to set the borders first.

2 different border styles.

4 different border styles.

3 different border styles.

2 different border styles.

1 border style.

This property is a shorthand property for border-width, border-style, and border-color.

The border-radius Property

This property is used to add rounded borders to an element:

Normal border

Round border

Rounder border

Roundest border

This div element has a top margin of 100px, a right margin of 150px, a bottom margin of 100px, and a left margin of 80px.

CSS Margins

This element has a margin of 70px.

The padding shorthand property - 4 values

This div element has a top padding of 25px, a right padding of 50px, a bottom padding of 75px, and a left padding of 100px.

Heading 1 (center)

Heading 2 (left)

Heading 3 (right)

The three headings above are aligned center, left and right.

Example text-align: justify

The text-align: justify; value stretches the lines so that each line has equal width (like in newspapers and magazines).

In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since. 'Whenever you feel like criticizing anyone,' he told me, 'just remember that all the people in this world haven't had the advantages that you've had.'