HOME | PHP Tutorial | CSS
facebook icon
AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP
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">
  <tr>
    <th>Firstname</th>
    <th>Lastname</th> 
    <th>Age</th>
  </tr>
  <tr>
    <td>Jilly</td>
    <td>Ford</td> 
    <td>55</td>
  </tr>
  <tr>
    <td>Eva</td>
    <td>Sonjak</td> 
    <td>48</td>
  </tr>
</table>
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.
Example2:
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Colspan/Rowspan</title>
</head>
<body>
<table border = "1">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr>
<td rowspan = "2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
<td>Row 1 Cell 3</td>
</tr>
<tr>
<td>Row 2 Cell 2</td>
<td>Row 2 Cell 3</td>
</tr>
<tr>
<td colspan = "3">Row 3 Cell 1</td>
</tr>
</table>
</body>
</html>

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">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>

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

2685. Tables : Table Tags - HTML Tutorial
HTML tables - HTML tutorial
http://www.echoecho.com/htmltables02.htm

873. Components of a HTML page - HTML tutorials - w3resource

https://www.w3resource.com/html/components-of-an-HTML-page.php

3195. How to add text, paragraf in HTML, html tutorial
How to add text, paragraf in HTML html tutorial
https://www.agernic.com/html-tutorial/how-to-add-text-in-html.html

2627. Forms : Password Field - HTML Tutorial
HTML forms - HTML tutorial
http://www.echoecho.com/htmlforms06.htm

2660. Images : Spacing Around - HTML Tutorial
HTML images - HTML tutorial
http://www.echoecho.com/htmlimages06.htm

2807. How to add text, paragraf in HTML, html tutorial
How to add text, paragraf in HTML html tutorial
http://www.agernic.com/html-tutorial/how-to-add-text-in-html.html

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 BETWEEN Operator
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 CREATE DATABASE - example
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