views:

219

answers:

4
+1  Q: 

CSS Reset question

I have a reset.css file that includes the following declaration: border:0 none;

So when I make a table like this:

<table border="1">

The border does not show up. How do I get the border to show up without removing the border:0 none; property? The code must be <table border="1">. Is there a way to make the table "ignore" the reset.css file? (This must work across all browsers as well including IE 6+)

+3  A: 

Add a style="border: 1px solid;" to the <table> tag. Styles override attribute settings.

James Keesey
Hi,It has to be border=1. There's a section of the site that I can't use css declarations inline like that. Can I make that section ignore the border:0 none; property and just use browser default?
Mike
Why can't you use inline styles but you can use other inline attributes like border? Border isn't used anymore (as an attribute) because of CSS.
Parrots
No because styles override any attribute settings there is no way to change it without using styles. You could use classes to differentiate the table types and have some without borders and some with. Using CSS selectors you can do some picking and choosing.
James Keesey
A: 

directly after your reset css add a line like this:

table.borderIgnore { border:auto; }

then for your table do this:

<table class="borderIgnore" border="1">

let me know if that works

Darko Z
A: 

Ok, so lets say you are in a jam, and lets assume:

  • You can't do anything suggested above
  • You can't use inline styles
  • You can't add a style to your html doc like:

    <style type="text/css">
      table { border: 1px solid; }
    </style>
    
  • You can't add a link to another stylesheet

Could you do something which is probably overkill, like use some javascript or jquery to do it?

<script type='text/javascript'>
  var tableStyle = "table { border: 1px solid;}";

  function appendStyle(tableStyle) {
    var css = document.createElement('style');
    css.type = 'text/css';

    if (css.styleSheet) css.styleSheet.cssText = tableStyle;
    else css.appendChild(document.createTextNode(tableStyle));

    document.getElementsByTagName("head")[0].appendChild(css);
  };

  window.onload = function() { 
    appendStyle(tableStyle); 
  };
</script>
Bobby
A: 

I have the same problem. I want the reset to apply to new content, but I have several thousand old pages relying on the browser default. I can't make the assumption that all of the legacy tables should get a border

Lee
This is really either a comment, or a question in its own right. But the easiest solution is to have a specific stylesheet that you reference in all new pages, and then work through your archive.
David Thomas
Your best bet is to use ALL of your pages with style sheets and just have the pages that don't need changing not use the classes or IDs. In the case that your legacy pages get updated, you already have the pages set up to use CSS, you just need to link the CSS and assign the classes and IDs.
tahdhaze09