Curriculum
Course: CSS
Login

Curriculum

CSS

CSS INTRODUCTION

0/1

CSS Selectors

0/1

CSS Comments

0/1

CSS Padding

0/1

CSS Box Model

0/1

CSS Combinators

0/1

CSS Pseudo-classes

0/1

CSS Pseudo-elements

0/1

CSS Dropdowns

0/1

CSS Image Gallery

0/1

CSS Image Sprites

0/1

CSS Counters

0/1

CSS Website Layout

0/1

CSS Specificity

0/1

CSS Math Functions

0/1
Text lesson

Table Style

Table Padding

To manage the distance between the border and the content within a table, apply the padding property to <td> and <th> elements.

First Name Last Name Savings
Peter Griffin $100
Lois Griffin $150
Joe Swanson $300

 

Example

th, td {
  padding: 15px;
  text-align: left;
}

Horizontal Dividers

First Name Last Name Savings
Peter Griffin $100
Lois Griffin $150
Joe Swanson $300

Include the border-bottom property in <th> and <td> elements to create horizontal dividers.

Example

th, td {
  border-bottom: 1px solid #ddd;
}

Hoverable Table

Apply the :hover selector to <tr> elements to highlight table rows when hovered over with the mouse.

First Name Last Name Savings
Peter Griffin $100
Lois Griffin $150
Joe Swanson $300

Example

tr:hover {background-color: coral;}

Striped Tables

First Name

Last Name

Savings

Peter

Griffin

$100

Lois

Griffin

$150

Joe

Swanson

$300

To create zebra-striped tables, utilize the nth-child() selector to target specific table rows and apply a background-color to every even (or odd) row.

Example

tr:nth-child(even) {background-color: #f2f2f2;}

Table Color

The following example defines the background color and text color for <th> elements.

First Name

Last Name

Savings

Peter

Griffin

$100

Lois

Griffin

$150

Joe

Swanson

$300

Example

th {
  background-color: #04AA6D;
  color: white;
}