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

  • Home
  • SEARCH
  • 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 3952128
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:48:49+00:00 2026-05-20T01:48:49+00:00

I am wondering about the following code: <html> <head> <title>Test HTML</title> <link rel=stylesheet type=text/css

  • 0

I am wondering about the following code:

<html>
        <head>
        <title>Test HTML</title>
        <link rel="stylesheet" type="text/css" href="test.css">
        </head>
<body>
<table class=foo cellpadding="2" cellspacing="2">
         <tr>
             <td><b>Contingency Table:</b></td>
             <td><table class=bar border="2" align="left">
                  <tr><td>blaa</td><td>blaa</td><td>blaa</td></tr>
                  <tr><td>blaa</td><td>blaa</td><td>blaa</td></tr>
                  <tr><td>blaa</td><td>blaa</td><td>blaa</td></tr>
               </table>
             </td>
         </tr>
</table>
</body>
</html>

with the following CSS:

table {
        border-width: 2px;
        border-spacing: 2px;
        border-style: solid;
        }  

table.bar {
        border-color: red;
        background-color: white;
}

table.bar td {
        background-color: green;
}

table.bar tr {
        background-color: black;
}

table.foo {
        border-color: blue;
        background-color: white;
}

table.foo td {
        border-color: black;
        background-color: yellow;
}

table.foo tr {
        background-color: yellow;
}

The problem is, when interchanging the classes “foo” and “bar” in the table and its nested table, the style of the td-tags is not correctly set, or at least as not as expected by me. When changing from outer “bar” and inner “foo” to outer “foo” and inner “bar” the colors change as expected, except for the colors of the td-element. What am I doing wrong here, since the other elements of a table change correctly?

I know that using table table.foo {...} would work, but this requires to know which style should be used for the inner/nested table and I don’t really like this idea. I want to be able to interchange the styles when desired and not include the “inheritance” in the style-sheet… Also dictating the order of the foo or bar styles in the style-sheet is not desirable for me. Please correct me, if this is actually common HTML/CSS practice.

  • 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-05-20T01:48:50+00:00Added an answer on May 20, 2026 at 1:48 am

    CSS – Cascading style sheets!

    Put simply, if you switch the foo and bar classes in you tables, you’ll also need to move the table.foo css rules above the table.bar classes.

    Explanation If bar is nested in foo the css rule table.foo td matches both the tds in both the foo and bar tables. So it the table.foo td is declared after the table.bar td rule, the table.foo td rule overwrites the table.bar td

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

Sidebar

Related Questions

I have been wondering about the following lines of code [self performSelector:@selector(myMethod) withObject:self afterDelay:1.0];
I am wondering about the the following piece of Java code: System.out.println. I am
I am wondering about the following C#-code: struct Structure { public Structure(int a, int
I'm wondering about the following. Giving this Code: function displayprops(obj, name) { console.log(name+:); for(var
The question's title may sound stupid, but I have beenw wondering about the following
I was wondering if the following code shows a bad practice (about interface inheritance):
I have written the following C99 code and was wondering about the struct declaration.
Reading this DZone article about Java concurrency I was wondering if the following code:
I have the following HTML: <div id=wrapper> <div class=p1> <a href=# class=quickFlipCta><img src=Test Pictures/QuestionMark.gif
I'm wondering how i would go about making the following application: a user signs

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.