New Contrast Pro UI Kit and template with 5 admin dashboards, 23 pages and 10000+ components for $49 ($50 off)🎉

HTML Tutorial: HTML Tables, Classes and Ids


By Emmanuel Chinonso

Web Developer

HTML Table

A html table is defined with the <table> tag. This allows html to arrange words in tabular form. Each table row is defined with the <tr> tag.

Contrast Bootstrap UI Kit

A table header is defined with the <th> tag. By default, the headings are bold and centered. A table data/cell is defined with the <td> tag.

HTML Code:

<table style = “width:100%>
<th> LastName </th>
<th> FirstName </th>
<th> Age </th>
<td> William</td>
<td> Sam</td>
<td> 30 </td>

Adding a border

You can add border using a CSS border property to the table

CSS Code:

Table, th, td {
Border: 1px solid black;

Don’t worry we are going to explain better on our CSS tutorial.

HTML Classes

The class attribute is used to specify a class for an HTML element. It is common to find multiple HTML elements sharing the same class.

HTML Code:

.cities {
Color: white;
Margin: 20px
Padding: 20px
<div class = “cities”>
<h2> London</h2>
<p> London is the capital of England </p>
<div class= “cities”>
<h2> Paris </h2>
<p> Paris is the capital of France </p>

HTML Id attribute

This is used to specify a unique id in an HTML document. It is used to point specific style declaration in a style sheet. It is also used by Javascript to access and manipulate or change the element with the specific ID.

The syntax is written with a hash character "#" followed by an id name.

HTML Code:

<!DOCTYPE html>
Color: black;
Padding: 40px;
Text-align: center;
<h1 id= “myHeader”>my Header</h1>

Difference between id and class

The difference lies in how they are used. A class name can be used by multiple HTML elements, while an id name must only be used by one html element within the page.

Create Stunning websites and web apps

Building different custom components in react for your web apps or websites can get very stressful. Thats why we decided to build contrast. We have put together a UI kit with over 10000+ components, 5 admin dashboards and 23 additional different pages template for building almost any type of web app or webpage into a single product called Contrast Pro.Try contrast pro


Contrast React Bootstrap PRO is a Multipurpose pro template, UI kit to build your next landing, admin, SAAS, prelaunch, etc project with a clean, well documented, well crafted template and UI components.Learn more about Contrast Pro