Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why html table cell's border color does not change?

Tags:

How can I make left border of the cell red? Why this does not work? Thanks!!

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.main-table {
    border-collapse: collapse;
}
.main-table td {
    margin: 0px;
    padding: 0px;
    border: 1px solid #aaa;
    padding: 1px 4px 1px 4px;
}
.left-border {
border-left: 1px solid red !important;
}
</style>
</head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>

Shouldn't left-border override the color specified on .main-table td?

<table class='main-table' cellspacing='0' cellpadding='0'>
<tr>
    <td> 1 </td>
    <td> 366 </td>
</tr>
<tr>
    <td > 2 </td>
    <td class='left-border'> 777 </td>
</tr>
</table>

</body>
</html>
like image 543
vrepsys Avatar asked Jan 18 '12 06:01

vrepsys


People also ask

How do you change the border-color of a cell in HTML?

To change the border's color, use the attribute bordercolor="color" where color is the same format as all the other web colors we've been using. The table below has the bordercolor set to #ff00ff with the table tag <table bordercolor="#ff00ff">. To change the background color, use the attribute bgcolor="color".

How do I change the color of a border in a table?

Select the Table Tools / Design tab on the ribbon. Select one of the following in the Draw Borders group: Use Pen Color to change the color of the border. If you want more color options, click More Border Colors, and then either click the color that you want on the Standard tab, or mix your own color on the Custom tab.

Why is the table border not showing HTML?

If you've set the shorthand border property in CSS and the border is not showing, the most likely issue is that you did not define the border style. While the border-width and border-color property values can be omitted, the border-style property must be defined. Otherwise, it will not render.

Can you give Colours to the borders of a table in HTML?

With the border-color property, you can set the color of the border.


2 Answers

Set the border to 1px double red. A 1px-wide "double" border looks identical to a "solid", but has higher precedence in collapsed border computation.

like image 132
Niet the Dark Absol Avatar answered Oct 03 '22 05:10

Niet the Dark Absol


Try this,

.main-table {
    border-collapse: collapse;
}
.left-border {
border-left: 2px solid red !important;
}
like image 31
anglimasS Avatar answered Oct 03 '22 04:10

anglimasS