Reputation: 3020
I have a piece of HTML that I need to modify and I need to keep the changes minimal (out of CSS). All I need to do is to hide a table cell until something happens. So I went ahead and added the style tag as shown below:
<td style="display:none;">
However, this causes the style class to reset, e.g. the cell which used to be vertically center-aligned is now top-aligned, and so on. My understanding is that this is because the style attribute overrides the default CSS stuff. Is that correct? If yes, how can I prevent it? I just need to add the display attribute, not reset the rest of style attributes.
I spend some time searching online and noticed that HTML5 has introduced something called scoped style. Is there an HTML4 easy-to-do equivalent for it?
Upvotes: 0
Views: 170
Reputation: 71384
It might be because doing display:none
remove the node from the DOM display calculation. You no longer have a placeholder for that cell in your table. You might try visibility:hidden
, which will have the DOM element keep its place in the document rendering but just not be visible.
Upvotes: 3
Reputation: 1728
Try visibility:hidden;
instead of display:none;
Let me know if that does the trick.
Upvotes: 1