Mariah
Mariah

Reputation: 727

How to maintain class styling when placed in a table?

How can I keep maintain the following "MyDiv" styling when placed into a table? The font type changes and size when it (div class="MyDiv") is in a table.

<table>
  <tr>
    <td><div class="MyDiv">Text Here</div></td>   <!-- Loses own defined style when place in a table -->
    ...more cols..
   </tr>
</table>

table {font-family: Calibri;...}
.MyDiv, MyDiv {font-family: Verdana;...}

Sorry, I'll submit to ridicule as I'm not HTML savvy. Thx

Upvotes: 0

Views: 50

Answers (1)

Robert Van Sant
Robert Van Sant

Reputation: 1507

first if you're using divs, you don't need to use a table. you could style a div to act just like a table, plus it's more lightweight on the browser. just add styling to the table, either inlined or in the css and the divs within the table should inherit the parent styles.

<table class="MyDiv">

or

<table style="CSS_DEFINITION">

if this still gives you trouble within your css, perhaps you have other styles defined, i'd say use an explicit definition like:

.MyDiv.div { DEFINITION }

i hope this helps

Upvotes: 1

Related Questions