Curriculum
Course: HTML Basic
Login

Curriculum

HTML Basic

HTML Introduction

0/1

HTML Editors

0/1

HTML Elements

0/1

HTML Attributes

0/1

HTML Headings

0/1

HTML Paragraphs

0/1

HTML Styles

0/1

HTML Formatting

0/1

HTML Quotation

0/1

HTML Comments

0/1

HTML Colors

0/1

HTML Favicon

0/1

HTML Page Title

0/1

HTML Block and Inline

0/1

HTML Iframes

0/1

HTML Java Script

0/1

HTML File Paths

0/1

HTML - The Head Element

0/1

HTML Style Guide

0/1

HTML Entities

0/1

HTML Symbols

0/1
Text lesson

Table Borders

How To Add a Border

To incorporate a border, apply the CSS border property to the table, th, and td elements.

Image

 

Example

table, th, td {
  border: 1px solid black;
}

Collapsed Table Borders

To prevent the occurrence of double borders as shown in the example above, establish the CSS border-collapse property as collapse.

This action will cause the borders to merge into a single border.

Image

 

Example

table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}

Style Table Borders

When you assign a background color to each cell and set the border color to white (matching the document background), it creates the illusion of an invisible border.

Image

 

Example

table, th, td {
  border: 1px solid white;
  border-collapse: collapse;
}
th, td {
  background-color: #96D4D4;
}

Round Table Borders

Using the border-radius property results in rounded corners for the borders.

Image

 

Example

table, th, td {
  border: 1px solid black;
  border-radius: 10px;
}

Exclude the table from the CSS selector to omit the border around it.

Image

 

Example

th, td {
  border: 1px solid black;
  border-radius: 10px;
}

Dotted Table Borders

The border-style property allows you to define the visual style of the border.

Image

The subsequent values are permissible:

  • dotted     
  • dashed     
  • solid     
  • double     
  • groove     
  • ridge     
  • inset     
  • outset     
  • none     
  • hidden

Example

th, td {
  border-style: dotted;
}

Border Color

Using the border-color property enables you to specify the color of the border.

Image

 

Example

th, td {
  border-color: #96D4D4;
}

 

Click to Learn