Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7717445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:54:02+00:00 2026-06-01T02:54:02+00:00

I have an HTML table with collapsed and adjacent borders and a standard border

  • 0

I have an HTML table with collapsed and adjacent borders and a standard border on all cells and I want to change the border color of a specific row to something else. The problem is that when the borders are collapsed and neighboring cells have different colors (or styles in general I assume) the browser does not render in a visually acceptable manner.

Here’s my HTML:

<table>
    <tr><td>Lorem</td><td>Ipsum</td></tr>
    <tr><td>Lorem</td><td>Ipsum</td></tr>
    <tr id="foo"><td>The border of these cells</td>
                 <td>is not uniformly red!</td></tr>
    <tr><td>Lorem</td><td>Ipsum</td></tr>
</table>

The CSS:

table { border-collapse: collapse; border-spacing: 0 }
td { padding: 5px; border: 3px black solid; }
#foo td { border: 3px red solid; }

There is also a JSFiddle of the above.

How different browsers render it:

IE 7 (standards):

IE 7 standards

IE 8 and 9 (standards):

IE 8, 9 standards

Firefox 11 (note the subtle visual artifact on the left red border and the quirky way it chooses to render the corners):

FF 11

Chrome 18:

Chrome 18

The question: What can I do to get a visually acceptable render? Can that render be the ideal of “red borders always take precedence over black ones”?

Clarification:

I am first and foremost looking for a pure CSS solution.

If this is not possible, I would work with something that requires small and localized modifications (i.e. not something I ‘d have to do on every table everywhere).

Javascript is acceptable, since in the actual website the styles that control the borders are applied dynamically based on user interaction. The event handlers are set up by code almost identical to this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:54:03+00:00Added an answer on June 1, 2026 at 2:54 am

    I came to this solution without extra-markup : http://jsfiddle.net/fcalderan/PAJzK/12/

    the idea is to avoid using border-collapse and using border top/right for table cells and border bottom-left for table element.

    tried with IE8, FX11 and CH17, here’s the relevant CSS

    table {  
        border-spacing : 0;
        border-left    : 3px black solid;
        border-bottom  : 3px black solid;
    }
    
    td { 
        padding      : 5px; 
        border-right : 3px black solid; 
        border-top   : 3px black solid;
    }
    
    #foo td { border-color:red; }
    
    
    /* border left red-coloured using :before pseudoelement */
    #foo td:first-child:before { 
        content       : ""; 
        position      : relative;
        margin-left   : -8px;
        padding       : 8px 0 8px 5px;
        border-left   : 3px red solid;
    }
    
    /* top border of next rows red coloured */
    #foo + tr td {  
        border-top: 3px red solid;  
    }
    

    here an issue occurs if the highlighted row is the last one: in that case #foo + tr td wouldn’t match anything : in that case you could write instead this rule

    #foo td:after {
       content    : "";
       position   : relative;
       margin     : 0 0 0 -8px;
       display    : block;
       width      : 100%;
       height     : 3px; 
       padding    : 0 8px;
       top        : 2px;
       margin-bottom : -6px;
       border-bottom : 3px red solid;
    }
    

    see example in http://jsfiddle.net/fcalderan/PAJzK/14/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want the header cells of a table to have a specific border color
I have a html table with CSS. Currently all the cells have a white
I have a HTML table like this: <table border=1> <tbody> <tr> <td><a href=# class=delete>DELETE
I have a HTML table like this: <table border=1> <tbody> <tr> <td><a href=# class=delete>DELETE
I have an html table rendered page and I want to save it as
I have a HTML table which I want to make fluid so that when
I have a very specific html table construct that seems to reveal a Gecko
I have a HTML table where I must set the overall width and want
I have an HTML table with one column being email addresses; spambot issues aside,
I have an HTML table with a large number of rows, and I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.