Open In App

What is the rule attribute in HTML Table ?

Last Updated : 13 Jan, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

This is an HTML attribute, that is used to specify which parts of the inside borders should be visible. The HTML rule attribute is applicable on table tags. The <table> rules attribute is not supported by HTML 5.

Syntax:

<table rules="value">

Attributes: This attribute accepts 5 values all are mentioned and described below.

  • none: It does not create any lines.
  • groups: It creates lines between row and column groups.
  • rows: It creates a line between the rows.
  • cols: It creates lines between the columns.
  • all: It creates lines between the rows and columns.

Example: The below example illustrates the rule attribute in HTML.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <style>
        h1 {
            color: green;
        }
    </style>
</head>
  
<body>
    <center>
    <h1>GeeksforGeeks</h1>
  
    <h2>What is rule attribute in HTML Table?</h2>
  
    <table rules="rows">
        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
        <tr>
            <td>BITTU</td>
            <td>22</td>
            <td>CSE</td>
        </tr>
    </table>
    <br>
    <table rules="cols">
        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
        <tr>
            <td>BITTU</td>
            <td>22</td>
            <td>CSE</td>
        </tr>
    </table>
    <br>
    <table rules="all">
        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
        <tr>
            <td>BITTU</td>
            <td>22</td>
            <td>CSE</td>
        </tr>
    </table>
    </center>
</body>
  
</html>


Output:

HTML rule attribute in HTML Table



Previous Article
Next Article

Similar Reads

How href attribute is different from src attribute in HTML ?
In HTML5, the href and src attributes play distinct roles in defining paths or URLs, each associated with specific HTML elements. The href attribute, commonly found in an anchor (&lt;a&gt;) elements, points to the destination of hyperlinks, facilitating navigation. The src attribute, used with elements like &lt;img&gt; and &lt;script&gt;, specifies
1 min read
HTML | &lt;table&gt; bgcolor Attribute
The HTML &lt;table&gt; bgcolor Attribute is use to specify the background color of a table.Syntax: &lt;table bgcolor="color_name | hex_number | rgb_number"&gt; Attribute Values: color_name: It sets the text color by using the color name. For example "red".hex_number: It sets the text color by using the color hex code. For example "#0000ff".rgb_numb
1 min read
HTML | &lt;table&gt; frame Attribute
The HTML &lt;table&gt; frame Attribute is used to specify the visibility of outside borders. Syntax: &lt;table frame="value"&gt; Attribute Values: void: It is used to hide the outside border. above: It is used to display the top outside border. below: It is used to display the bottom outside border. hsides: It is used to display the top and bottom
2 min read
HTML | &lt;table&gt; rules Attribute
The HTML &lt;table&gt; rules Attribute is used to specify which parts of the inside borders that should be visible. Syntax: &lt;table rules="value"&gt; Attribute Values: none: It does not create any lines.groups: It create lines between row and column groups.rows: It creates line between the rows.cols: It creates line between the columns.all: It cr
1 min read
HTML | &lt;table&gt; summary Attribute
The HTML &lt;table&gt; summary Attribute is used to specify the summary of the table content. Syntax: &lt;table summary="text"&gt; Attribute Values: text: It holds the summary of the table content. Note: The &lt;table&gt; summary Attribute is not supported by HTML 5. Example: &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt; HTML table
1 min read
HTML | &lt;table&gt; width Attribute
The HTML &lt;table&gt; width Attribute is used to specify the width of a table. If width attribute is not set then it takes default width according to content. Syntax: &lt;table width="pixels | %"&gt; Attribute Values: pixels: It sets the width of table in terms of pixels. %: It sets the width of table in terms of percentage (%). Note: The &lt;tabl
1 min read
HTML &lt;table&gt; align Attribute
The HTML &lt;table&gt; align Attribute is used to specify the alignment of the table and its content. Instead of the align attribute, CSS properties like margin and text-align are preferred for table alignment. For aligning content within table rows or cells, use the align attribute within &lt;tr&gt; and or apply CSS styles. Note: This attribute is
2 min read
HTML &lt;table&gt; cellpadding Attribute
The HTML &lt;table&gt; cell padding Attribute is used to specify the space between the cell content and cell wall. The cellpadding attribute is set in terms of pixels. By default, the padding is set to 0. Note: The &lt;table&gt; cellpadding Attribute is not supported by HTML5. Syntax:&lt;table cellpadding="pixels"&gt;Attribute Values:pixels: It hol
1 min read
HTML &lt;table&gt; cellspacing Attribute
The HTML &lt;table&gt; cellspacing Attribute is used to specify the space between the cells. The cellspacing attribute is set in terms of pixels. If the cellspacing attribute is not explicitly set, most browsers will apply a default spacing of 1 pixel. Note: The &lt;table&gt; cellspacing Attribute is not supported by HTML 5. Syntax:&lt;table cellsp
2 min read
HTML &lt;table&gt; border Attribute
The HTML &lt;table&gt; border Attribute is used to specify the border of a table. It sets the border around the table cells. This attribute defines the visual presentation of the table by setting the thickness of the borders. A higher value results in a thicker border. Alternatively, setting the border attribute to "0" removes the borders entirely.
3 min read