Home > Web Front-end > HTML Tutorial > How to use HTML tags in HTML tables?

How to use HTML tags in HTML tables?

王林
Release: 2023-09-08 18:13:01
forward
1648 people have browsed it

We can easily add HTML tags to the table. HTML tags should be placed within

tags. For example, add a paragraph

tag or other available tags within a tag.

How to use HTML tags in HTML tables?

grammar

The following is the syntax for using HTMl tags in HTML tables.

<td>
   <p> Paragraph of the context</p>
<td>
Copy after login

Example 1

An example of using HTML tags in an HTML table is given below.

<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <style>
      table,tr,th,td {
         border:1px solid black;
      }
   </style>
</head>
<body>
   <table style="width: 50%">
      <caption style="text-align: center; ">Employees</caption>
      <tr>
         <th >EmployeeName</th>
         <th >About Employee</th>
      </tr>
      <tr>
         <td >Yadav</td>
         <td ><p>Lokesh yadav is a content developer at tutorialspoint.</p></td>
      </tr>
      <tr>
         <td>Abdul</td>
         <td ><p>Abdul is a content developer at tutorialspoint.</p></td>
      </tr>
   </table>
</body>
</html>
Copy after login

The following is the output of the above example program.

We can also add other HTML tags to the HTML table.

Example 2

The following is the syntax for using HTMl tags in HTML tables.

<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <style>
      table,tr,th,td {
         border:1px solid black;
      }
   </style>
</head>
<body>
   <table style="width: 50%">
      <caption style="text-align: center; ">Employees</caption>
      <tr>
         <th>EmployeeName</th>
         <th>Languages Known</th>
      </tr>
      <tr>
         <td>Yadav</td>
         <td><ul>
            <li>HTML</li>
            <li>Java</li>
            <li>C</li>
         </ul></td>
      </tr>
      <tr>
         <td>Abdul</td>
         <td ><ul>
         <li>C#</li>
         <li>Java</li>
         <li>C</li>
         </ul></td>
      </tr>
   </table>
</body>
</html>
Copy after login

The following is the output of the above example program.

Example 3

Another example of using HTML tags in HTML tables is as follows -

<!DOCTYPE html>
<html>
<head>
   <style>
      table, th, td { border: 1px solid black; width: 400px; }
   </style>
</head>
<body>
   <h1> Total Points</h1>
   <table>
      <tr>
         <th>Technologies</th>
         <th>Points</th>
      </tr>
      <tr>
         <td>Programming Languages
         <ul>
         <li>C++</li>
         <li>Java</li>
         <li>C</li>
        </ul>
         </td>
         <td>100</td>
      </tr>
      <tr>
         <td>Database
         <ul>
         <li>MySQL</li>
         <li>Oracle</li>
         <li>CouchDB</li>
         </ul>
         </td>
         <td>50</td>
      </tr>
   </table>
</body>
</html>
Copy after login

The above is the detailed content of How to use HTML tags in HTML tables?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template