1

I have a table that has a static width set with inline css.

<table style="width:700px;"></table>

I cannot control the markup, and I'd like to use CSS to give that table a width of 100%. One solution is to use "display:block" to prevent the table from overflowing, but then the table cells collapse to the size of their contents, which is not what I want. Is this possible?

Here's a JSFiddle to illustrate the problem.

I've encountered many questions like this, but not this particular question. Here are some similar SO questions in case they're helpful to others:

CSS width and max-width combined

CSS: table {width:100%; display:block;} not working in Firefox

Community
  • 1
  • 1
launchoverit
  • 4,807
  • 4
  • 20
  • 23

2 Answers2

4

Use CSS's !important declaration

table{
    width:100% !important;
}
Community
  • 1
  • 1
JKirchartz
  • 17,612
  • 7
  • 60
  • 88
  • Welp, "I swear I tried that", but apparently not. Marking this as the answer unless somebody has a solution that doesn't use !important. Thanks! – launchoverit Jul 08 '16 at 18:32
0

You have to make a style that says my custom style is more important than the "default" style.

To do that you have to use the !important clause.

table{ width: 100% !important; }

The above should give you what you want.

Mike June Bug Captain
  • 1,013
  • 1
  • 7
  • 15