HOME | PHP Tutorial | CSS
facebook icon
HTML Tutorial

CSS Tutorial

HTML table

The HTML table allows to arrange all data on the page like, text, images, links, forms, etc. into rows and columns of cells.
The HTML tables are created using the <table> tag, <tr> tag is used to create table rows and <td> tag is used to create data cells. The elements under <td> are regular left aligned by default.

HTML table border, HTML table style, table width

An HTML table is defined with the <table> tag where we add style with: width, border color and more .
Example 1:
<table style="width:100%; border:#C30 thin solid; text-align:center">
Note: HTML image alt attribute. The value of the alt attribute from above example 1 should describe the image what it looks like.
The html cod above will display this HTML table result:
HTML table border, HTML table style, table width, text-align:center result.
Firstname LastnameAge
Jilly Ford55
Evea Sonjak48

HTML table Colspan and Rowspan Attributes

Yf you want to merge two or more columns into a single column you will use colspan attribute. If you want to merge two or more rows you will use rowspan.
<!DOCTYPE html>
<title>HTML Table Colspan/Rowspan</title>
<table border = "1">
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<td rowspan = "2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
<td>Row 1 Cell 3</td>
<td>Row 2 Cell 2</td>
<td>Row 2 Cell 3</td>
<td colspan = "3">Row 3 Cell 1</td>

This HTML code will produce the following result −
Column 1 Column 2 Column 3
Row 1 Cell 1 Row 1 Cell 2 Row 1 Cell 3
Row 2 Cell 2 Row 2 Cell 3
Row 3 Cell 1

HTML Table Height and Width

You can specify table width and tabele height in pixels or percentage of available screen area.
Example 3:
<table border = "2" width = "450" height = "160">
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>

This HTML code will produce the following result −
Row 1, Column 1 Row 1, Column 2
Row 2, Column 1 Row 2, Column 2

HTML table, border, width, style, center, color, colspan, tag, rowspan, example, tag, css HTML table style, HTML border, width and height - html tutorial

2620. Basics : How to Learn More - HTML Tutorial
HTML basics - HTML tutorial

2118. HTML Tutorial - Comments into HTML codes
Commenting the html codes

2678. Metatags : Introduction - HTML Tutorial
HTML metatags - HTML tutorial

2626. Forms : Text Field - HTML Tutorial
HTML forms - HTML tutorial

2153. HTML Tutorial - Text Links, creating and using them
Text link how to use them

2673. Links : Link to New Window - HTML Tutorial
HTML links - HTML tutorial

Your add here
How to get PHP errors to display?
How to prevent sql injection in php mysqli
How do I get PHP errors to display - PHP error_reporting()
mysql_query(): The mysql extension is deprecated and will be removed i
Function eregi_replace() is deprecated in php - How to fix
PHP delete an element from an array
Uncaught Error: Call to undefined function MYSQL_NUM_ROWS() in
Deprecated: mysql_connect() mysql extension is deprecated and will be
mysqli_fetch_array() expects parameter 1 to be mysqli_result boolean g
SQL IN Operator - example
SQL like syntax and example
SQL WHERE AND & OR multiple conditions
SQL create table primary key autoincrement
PHP mysqli_connect () Function
SQL COUNT(), AVG() and SUM() Functions
Display data from SQL database with MySQLi into php - html table
SQL mysql order by columns, by date, by asc, by desc, random with PHP
PHP mysqli_query() Function - mysqli query
SQL delete row - SQL delete table
SQL update - SQL update select
Insert into SQL - Insert into table SQL - Insert data in sql
Login in PHP - simple login script with PHP MYSQL