views:

94

answers:

2

I am trying to create a div on my site that is supposed to work like the descriptions on Ebay where all the css styles of the main site are stripped off and then whatever styles are in the div are what style the div (if you can understand what I mean). I've been trying to use a reset stylesheet, but my problem is that the reset is also resetting anything I put into the div. For example the following:

<div class="reset_this_div">
  <font color="red">This is reformatted</font>
</div>

should reset the css in the div, then make the text "This is reformatted" red with the font tag. However, the reset seems to be overriding the font tag and the text just stays black. Does anyone know how I can fix this?

Thanks!

A: 

You need to define a CSS rule for the text. Give it a class. E.g.

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Test</title>
        <style>
            .reset * { color: black; }         
            .red { color: red; }
        </style>
    </head>
    <body>
        <div class="reset"><span class="red">text</span></div>
    </body>
</html>

Note that I replaced the since 1998(!) deprecated <font> tag by a <span>.

BalusC
A: 

Have you considered using one div inside another instead of using the tag?. Something like this:

<div class="reset_this_div">
  <div style="color: red !important;">This is reformatted</div>
</div>

Regards

David Conde
I have, although the contents of the div aren't static - its user-submitted HTML, the contents of a textarea submitted on a previous page so practically anything could be in there thats kind of why I'm trying to reset everything and then let the user style their own html.
Derek
but the problem with color happens only with <font>, so you must consider that the <font> tag is already deprecated, like BalusC said, so, good support for this tag would be impossible to give to that code
David Conde