elibraryportal Logo

CSS Table Example

Student Name Roll No Course
Pradeep 01 MCA
Priyanka Bhardawaj 02 M.com
Chiranjeevi 03 P.hd
Deepak Kumar 04 P.hd

Test it Now

Table Borders

This CSS border property specify the table borders

Example:-

Test it Now

CSS Table Width

Example:-

Test it Now

Collapse Table Borders

This property border-collapse is used to collapsed into a single border.

Example:-

Test it Now

CSS Table Width and Height

Use width and height properties.

Example:-

Test it Now

CSS Table Alignment

Alignment NameProperties
Horizontal Alignmenttext-align: center;
Vertical Alignmenttext-align: left;

Example:-

Test it Now

CSS Table Style


Table Padding

Ther padding is use to control the space between the border and the content in a table.

Example:-

Test it Now

Horizontal Dividers

Name Roll No. Course
Pradeep Kumar 1122514036 MCA
Naveen Kumar 1122514034 MCA
Ramanuj Kumar 1122514052 MCA
Sarvesh Kumar 1122514054 MCA

Add this border-bottom property to <th> and <td> for horizontal dividers:

Example:-

Test it Now

Table Color

background color and text color of <th> elements:

Name Course College//University
Pradeep MCA Accurate Institute of Management & Tech.
Priyanka Kumari M.com Magadh University Bodh Gaya
Deepak Kumar Docotor Ranchi/ Jharkhand University

Example:-

Test it Now

Mouse Hoverable Table

Use this :hover selector on <tr> to highlight table rows on mouse over:

Name Course College//University
Pradeep MCA Accurate Institute of Management & Tech.
Priyanka Kumari M.com Magadh University Bodh Gaya
Deepak Kumar Docotor Ranchi/ Jharkhand University

Example:-

Test it Now

Responsive Table

horizontal scroll bar if the screen is too small to display the full content:

Example:-

Test it Now