
HTML Topics
- HTML Intro
- HTML Basic
- HTML Editors
- HTML CSS
- HTML Tags
- <!--...-->
- <!DOCTYPE>
- <a>
- <abbr>
- <address>
- <area>
- <article>
- <aside>
- <audio>
- <b>
- <base>
- <bdi>
- <bdo>
- <bgsound>
- <blink>
- <blockquote>
- <body>
- <br>
- <button>
- <canvas>
- <caption>
- <cite>
- <code>
- <col>
- <colgroup>
- <data>
- <datalist>
- <dd>
- <del>
- <details>
- <dfn>
- <dialog>
- <div>
- <dl>
- <dt>
- <em>
- <embed>
- <fieldset>
- <figcaption>
- <figure>
- <footer>
- <form>
- <h1> to <h6>
- <head>
- <header>
- <hgroup>
- <hr>
- <html>
- <i>
- <iframe>
- <img>
- <input>
- <ins>
- <kbd>
- <label>
- <legend>
- <li>
- <link>
- <main>
- <map>
- <mark>
- <menu>
- <meta>
- <meter>
- <nav>
- <noscript>
- <object>
- <ol>
- <optgroup>
- <option>
- <output>
- <p>
- <param>
- <picture>
- <pre>
- <progress>
- <q>
- <rp>
- <rt>
- <ruby>
- <s>
- <samp>
- <script>
- <search>
- <section>
- <select>
- <small>
- <source>
- <span>
- <strong>
- <style>
- <sub>
- <summary>
- <sup>
- <svg>
- <table>
- <tbody>
- <td>
- <template>
- <textarea>
- <tfoot>
- <th>
- <thead>
- <time>
- <title>
- <tr>
- <track>
- <u>
- <ul>
- <var>
- <video>
- <wbr>
- HTML Deprecated Tags
- HTML Events
- HTML Event Attributes
- HTML Global Attributes
- HTML Attributes
- HTML Comments
- HTML Entity
- HTML Head
- HTML Form
- HTML IndexedDB
- HTML Drag & Drop
- HTML Geolocation
- HTML Canvas
- HTML Status Code
- HTML Language Code
- HTML Country Code
- HTML Charset
- MIME Types
HTML tr Tag

Photo Credit to CodeToFun
Introduction
In the world of web development, the <tr>
tag is a fundamental HTML element used for defining rows within an HTML table.
This comprehensive guide will walk you through the ins and outs of utilizing the HTML <tr>
tag effectively.
What is <tr> Tag?
The <tr>
tag, short for table row, is an essential component in the construction of HTML tables. It serves as the container for individual rows, providing structure and organization to tabular data.
Syntax
To implement the <tr>
tag, use the opening <tr>
and closing </tr>
tags to encapsulate the content of a table row. Typically, <tr>
tags are nested within the <table> element.
<tr>
<!-- Your table data (td) or table header (th) elements go here -->
</tr>
Attributes
While the <tr>
tag itself doesn't have many attributes, it plays a crucial role in structuring tables. Attributes like align or valign can be applied to individual <td> or <th> elements within the row to control alignment.
<tr align="center">
<td>Column 1</td>
<td>Column 2</td>
</tr>
Common Use Cases
Basic Table Row:
The primary purpose of the
<tr>
tag is to define a basic table row. This is achieved by nesting <td> (table data) elements within the<tr>
tags.basic-table-row.htmlCopied<tr> <td>Data 1</td> <td>Data 2</td> </tr>
Table Header Row:
For header rows, use the <th> (table header) element within the
<tr>
tags to denote headers instead of data.table-header-row.htmlCopied<tr> <th>Header 1</th> <th>Header 2</th> </tr>
Browser Support
Understanding the compatibility of the <tr>
tag across different browsers is essential for delivering a consistent user experience. Here's an overview of its support:
- Google Chrome: Fully supported.
- Mozilla Firefox: Fully supported.
- Microsoft Edge: Fully supported.
- Safari: Fully supported.
- Opera: Fully supported.
- Internet Explorer: Fully supported.
Best Practices
- Always nest
<tr>
tags within a <table> element. - Combine with <td> or <th> elements to create complete rows.
- Use CSS for advanced styling and layout customization.
Conclusion
Mastering the <tr>
tag is essential for web developers working with tabular data. By understanding its syntax, attributes, and use cases, you can create well-structured HTML tables that effectively present data on the web.
Join our Community:
Author

For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.
Buy me a coffee to make codetofun.com free for everyone.
Buy me a Coffee
If you have any doubts regarding this article (HTML tr Tag), please comment here. I will help you immediately.