How to set the collapsing borders model for a table ? Last Updated : 22 May, 2023 Comments Improve Suggest changes Like Article Like Report CSS describes the way HTML elements should be displayed. There are various CSS properties that can add magic to the basic HTML document. This article is focused on setting the collapsing borders model for the table element of HTML. HTML tables allow us to arrange our data using rows and columns. The <table> tag defines an HTML table. Each table row is defined with a <tr> tag. Each table header is defined with a <th> tag. Each table data/cell is defined with a <td> tag. Let us see how we can construct a table that can represent the marks of four students in their respective subjects and set the collapsed borders for it as shown below. Example 1: This example describes the basic example of an HTML table. HTML <!DOCTYPE html> <html> <head> <title>css collapse borders</title> </head> <body> <table> <tr> <th>Id</th> <th>Name</th> <th>Physics</th> <th>Chemistry</th> <th>Maths</th> </tr> <tr> <td>100</td> <td>Tanmay</td> <td>98</td> <td>96</td> <td>93</td> </tr> <tr> <td>101</td> <td>Sunaina</td> <td>90</td> <td>92</td> <td>91</td> </tr> <tr> <td>102</td> <td>Tanisha</td> <td>89</td> <td>86</td> <td>83</td> </tr> <tr> <td>103</td> <td>David</td> <td>97</td> <td>95</td> <td>94</td> </tr> </table> </body> </html> Output: HTML Table Example 2: In this example, we will add some borders to it using the CSS border property as shown in the below example. HTML <!DOCTYPE html> <html> <head> <title>CSS border collapse</title> <style> table, tr, th, td { border: 2px solid black; border-spacing: 5px; } </style> </head> <body> <table> <tr> <th>Id</th> <th>Name</th> <th>Physics</th> <th>Chemistry</th> <th>Maths</th> </tr> <tr> <td>100</td> <td>Tanmay</td> <td>98</td> <td>96</td> <td>93</td> </tr> <tr> <td>101</td> <td>Sunaina</td> <td>90</td> <td>92</td> <td>91</td> </tr> <tr> <td>102</td> <td>Tanisha</td> <td>89</td> <td>86</td> <td>83</td> </tr> <tr> <td>103</td> <td>David</td> <td>97</td> <td>95</td> <td>94</td> </tr> </table> </body> </html> Output: HTML table with borders On adding the borders to our table, we get the output as shown above. But this may not be the required output, So let us try to collapse these borders to get a more unified output using the border-collapse property and setting its value to collapse as shown in the next example. Example 3: In this example, we are using the above-explained approach border-collapse property. HTML <!DOCTYPE html> <html> <head> <title>CSS border collapse</title> <style> table, tr, th, td { border: 2px solid black; border-collapse: collapse; border-spacing: 5px; } </style> </head> <body> <table> <tr> <th>Id</th> <th>Name</th> <th>Physics</th> <th>Chemistry</th> <th>Maths</th> </tr> <tr> <td>100</td> <td>Tanmay</td> <td>98</td> <td>96</td> <td>93</td> </tr> <tr> <td>101</td> <td>Sunaina</td> <td>90</td> <td>92</td> <td>91</td> </tr> <tr> <td>102</td> <td>Tanisha</td> <td>89</td> <td>86</td> <td>83</td> </tr> <tr> <td>103</td> <td>David</td> <td>97</td> <td>95</td> <td>94</td> </tr> </table> </body> </html> Output: Table with collapsed borders This is our required output, So finally we have learned how to set the collapsed borders for a table. The point to remember is that the border-spacing property will have no effect on the border-collapse property when set to collapse value. Comment More infoAdvertise with us Next Article How to set the collapsing borders model for a table ? T tanyagarg3434 Follow Improve Article Tags : Web Technologies HTML CSS HTML-Tags CSS-Properties HTML-Questions CSS-Questions +3 More Similar Reads How to Create a Collapsed Border in HTML ? The border-collapse is a Property in CSS that is used to set the table borders. It should collapse into a single border or be separated from its border in HTML. Syntax:border-collapse: separate|collapse|initial|inherit;Properties:separate:Â This property is used to set a separate border of a cell. Th 2 min read How to Create Table Border in HTML ? In HTML, we can represent the data in the tabular format by using the <table> tag. We can customize the table by creating a border with different widths and colors. Below are the approaches to create a Table Border in HTML: Table of Content Using HTML Table Tag AttributesUsing HTML Inline Styl 2 min read How to Create Table in HTML with Border without CSS ? Creating tables in HTML remains an Important skill for over 80% of beginner web developers, especially when it comes to displaying structured data clearly. Tables help organize information into rows and columns, enhancing readability and layout. In this article, weâll explore how to create a basic H 2 min read How to set the table layout algorithm using CSS ? You can set the table layout algorithm using table-layout property which is used to display the layout of the table. In this article, you learn both auto and fixed layout algorithms to form table. Syntax: table-layout: auto|fixed; Approach 1: Using auto layout algorithm. Note: In the auto-layout alg 2 min read How to add border-bottom to table row <tr> in CSS ? A border is an important component of any table in HTML. It is used to define the boundaries of the table and its elements. The border-bottom property is used to add a border to the bottom of an HTML element. In this article, we will discuss how to add a border-bottom to table row <tr>. When a 3 min read HTML DOM Style borderCollapse Property The DOM Style borderCollapse property in HTML is used to set or return whether the border of the table collapsed into a single border or not. Syntax: It is used to return the borderCollapse property.object.style.borderCollapse It is used to set borderCollapse property.object.style.borderCollapse = " 2 min read Pure CSS Table with Horizontal Borders A table is an arrangement of data in rows and columns, or possibly in a more complex structure. Tables are widely used in communication, research, and data analysis. In Pure CSS, we will add a "pure-table" class to add styles to the table. This class adds padding and borders to table elements and em 2 min read How to Add Space Around Table Border in HTML ? Crafting visually appealing tables often involves adjusting the spacing between the content and the border. This guide dives into effective methods using HTML and CSS to achieve the desired spacing around your table's border, enhancing both readability and aesthetics. Below are the approaches to add 2 min read How to Auto Adjust Table td Width from the Content in HTML? HTML tables are needed to be displayed in responsiveness and adaptability across different screen sizes. Auto-adjusting table cell widths ensures that the table's layout adapts dynamically to the content, improving readability and usability. This can be done using different CSS properties like table 3 min read Like