Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    Apr 2011
    Posts
    81
    Member #
    27344
    Liked
    3 times
    I have a css table problem with the following table:

    tables.css Code –

    table,th,td
    {
    table-layout:fixed;
    border:1px solid #000000;
    border-collapse:collapse;
    margin-left:auto;
    margin-right:auto;
    width:600px;
    }

    th.normal
    {
    height:auto;
    padding:5px;
    background-color:#98eb5a;
    color:#000000;
    font-family:"Lucida Grande", Verdana, sans-serif;
    font-size:0.8em;
    }

    th.lred
    {
    height:auto;
    padding:5px;
    background-color:#ea3200;
    color:#ffffff;
    font-family:"Lucida Grande", Verdana, sans-serif;
    font-size:1em;
    }

    th.htitle
    {
    height:auto;
    padding:5px;
    background-color:#98e666;
    color:#000000;
    font-family:"Lucida Grande", Verdana, sans-serif;
    font-size:1.2em;
    }

    th.logo
    {
    height:auto;
    padding:0px;
    background-color:#98e666;
    font-family:"Lucida Grande", Verdana, sans-serif;
    }

    HTML file code –

    <html>
    <head>
    <link rel="stylesheet" type="text/css" media="screen" href="http://www.mywebsite/css/tables.css" />
    </head>

    <body>

    <table style="text-transform:uppercase; ">
    <col width="400px" />
    <col width="200px" />

    <tr>
    <th class="htitle">HEAD TITLE</th>
    <th class="logo"><img src="http://www.mywebsite/images/myimage.gif" alt="Something" /></th>
    </tr>
    </table>

    </body>

    </html>

    The table mentioned above in the html document is not taking the styles mentioned in the tables.css for “htitle” and “logo” classes. However, I am also using classes “lred” and “normal” on other tables and it is showing the css styles related perfectly.

    I am getting confused because they are practically the same except for colour and text size and they are showing differently.

    I am also clearing the cache every time I try to load the page, but I am having the same problem.

    I have no other css files which may effect with style inheritance.

    I can solve this problem by moving the style htitle and logo as an internal stylesheet, but i wish to keep my css external for sharing on other files.

    Can you please indicate what is the problem with my code?

    Thank You in advance.

  2.  

  3. #2
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    What exactly do you mean by "not taking the styles"? Does this mean that certain styles aren't applied or that all of the styles aren't applied?

    The one thing that jumps out at me on the surface is that your table, header cells and column cells all have the same width applied to them. That's an impossibility since your table has multiple columns.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  4. #3
    Member
    Join Date
    Apr 2011
    Posts
    81
    Member #
    27344
    Liked
    3 times
    The style for th.lred are being applied, while the styles for th.ltitle and th.logo are not being applied. That is my problem. Thank you for your intervention.

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    I think you misunderstood my question.

    If you add th class="ltitle", do you see none of the styles within ltitle or some of them? Usually you end up seeing some of them.

    Just to isolate the problem further, take one of the classes with the problem and add a color like this:

    color: #00A000 !important;

    Or replace the existing color. The key is the !important part. If you don't see green after the change, you know something's overriding it later on in your CSS. If you do, then something's overriding it within the CSS either before or after.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  6. #5
    Member
    Join Date
    Apr 2011
    Posts
    81
    Member #
    27344
    Liked
    3 times
    In effect, only some of them work. I can solve this problem by placing internal styles, but i wish to keep everything on the external stylesheet.

    Is there any way to prevent overriding of styles?

  7. #6
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    This actually happens fairly often. There are a few things you can do:

    1) Organize your CSS code so that elements, then classes, then IDs are processed in that order. You've done that, so that's a check.

    Supposedly CSS specificity will ensure that IDs are processed, then classes, then elements, but I've found that often isn't the case.

    2) If you're using any kind of grouping with your selectors (say table th), you'll have to override it with a similar pattern (table th.ltitle).

    3) Move your classes to the end just to see if something in the middle is overriding them.

    4) Put !important at the end of the selectors that don't show up. This is a last resort, however. Usually one of the first three is the case.

    If this works, try removing everything BUT the CSS classes and then slowly add your other classes, elements, IDs in (one at a time) and see if one of them throws the classes off.
    onlinespider likes this.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  8. #7
    Member
    Join Date
    Apr 2011
    Posts
    81
    Member #
    27344
    Liked
    3 times
    Thank You very much for your help. I will keep note of these and try to implement them.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:28 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com