1

I am trying to override a CSS style rule that is applying border-spacing of 0 to all tables. If I disable the rule in Firebug, my page looks the way I intend it to look. But I don't have the ability to remove or comment out the rule. So how can I override it back to its default value in my CSS file?

I'm using the latest Firefox version, if that's helpful.

Matt
  • 23,363
  • 39
  • 111
  • 152
  • @PaulProgrammer: I'm asking specifically about the `border-spacing` property, not the `display` property. – Matt Oct 28 '13 at 15:14
  • `border-spacing: initial` then. That's the thing about CSS is you should be able to generalize the rule that says "reset this to the initial value." – PaulProgrammer Oct 28 '13 at 15:14
  • The initial value for border-spacing *is* 0: http://www.w3.org/TR/CSS2/tables.html#separated-borders – cimmanon Oct 28 '13 at 15:17
  • @cimmanon - that may be the W3 CSS defined initial value, but browsers can override that in their own stylesheets. Do you know if Firefox overrides that? The lastest FF is the browser I'm supporting with this site (we got lucky with our clients). – Matt Oct 28 '13 at 15:18
  • Browsers typically do not use a non-standard default value. Display differences between browsers are typically localized to specific elements (Browser A might have h1 set to `font-size: 2em`, while Browser B might have `font-size: 1.8em`). Does this *only* happen in Firefox? Did you look in Firebug to see what the computed styles are for an unstyled table? – cimmanon Oct 28 '13 at 15:23
  • When I look under the Computed tab in Firebug, it doesn't list border-spacing as one of the computed styles for the table I have selected, and I removed any CSS that applies to the table. Not sure how to check it otherwise. In any case, I can always check the FF browser CSS files to see what it sets it to. So I'm gathering there really isn't a way to set it back to browser default without checking the browser CSS and setting the value to that explicitly... – Matt Oct 28 '13 at 15:26
  • It’s still a duplicate, even though the old question happens to mention `display` as an example. The correct answer is still the same (and different from the accepted answer there, but this question is *still* a duplicate). – Jukka K. Korpela Oct 28 '13 at 17:04
  • @Jukka, what is the correct answer? – Matt Oct 28 '13 at 19:55
  • The correct answer (which I recently wrote there, with some explanations) is “No.” – Jukka K. Korpela Oct 28 '13 at 20:02

1 Answers1

0

The styles Firefox applies to tables by default are as follows:

table {
    -moz-box-sizing: border-box;
    border-collapse: separate;
    border-spacing: 2px;
    display: table;
    margin-bottom: 0;
    margin-top: 0;
    text-indent: 0;
}

This is a non-standard value (it should be 0, as defined by the W3C), but you may find that most browsers agree on 2px as the default.

There is no way to return a property back to the browser's default for that element, you can only set it to a specific value.

James Donnelly
  • 126,410
  • 34
  • 208
  • 218
cimmanon
  • 67,211
  • 17
  • 165
  • 171
  • Thanks @cimmanon. It sounds like you're saying that there isn't a way to default the border-spacing value back to browser default without looking at the internal browser CSS styles and explicitly setting it to the value in the file. If you agree, please modify your answer to say that, and I'll accept it. – Matt Oct 28 '13 at 15:39
  • No W3C document normatively defines the default value. (CSS spec defines the initial value, but that’s a different things.) HTML5 CR specifies 2px as the “suggested default value”. But browsers may decide to use other default values. – Jukka K. Korpela Oct 28 '13 at 20:06