Course Homepage

CSS Borders & Padding Demo

1. Borders

Borders are like a frame around content. You can control thickness, style, and color.

This has a red solid 3px border.

2. Block vs Inline

Block elements stretch across the page. Inline elements only take up the space of their text.

I am a block element (DIV) with a dashed border.

Here’s an inline span with a dotted border inside a sentence.

3. Borders on One Side

You can put a border just on one side (top, right, bottom, left).

Border only on top

Border only on right

Border only on bottom

Border only on left

4. Padding

Padding is the space inside the border, between the text and the border.

Padding: 0px
Padding: 5px
Padding: 20px

5. Key Takeaway