Overriding styles

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sergey Ilinsky

    Overriding styles

    How can i override all the styles being cascaded applied to some HTML
    element?

    For example:
    I have a stylesheet where DIV styles are described
    DIV {
    padding: 10;
    margin: 10;
    }

    and have HTML code:

    <DIV><DIV style="override :all">Test</DIV></DIV>

    I would like to not have the inner DIV padding, margin and other
    directives described in styles above. Actually I would like to
    discover some directive line "override:a ll"!

    Please help me findning solution.

  • David Dorward

    #2
    Re: Overriding styles

    Sergey Ilinsky wrote:
    [color=blue]
    > How can i override all the styles being cascaded applied to some HTML
    > element?[/color]

    By *explicitly* setting different styles.
    [color=blue]
    > I have a stylesheet where DIV styles are described
    > DIV {
    > padding: 10;
    > margin: 10;
    > }[/color]

    Which is meaningless as non-zero lengths *must* have units. Some browsers
    will perform error recovery on that, but not all will.
    [color=blue]
    > and have HTML code:
    >
    > <DIV><DIV style="override :all">Test</DIV></DIV>[/color]

    There is no "override" property in CSS. So that is also meaningless.
    [color=blue]
    > I would like to not have the inner DIV padding, margin and other
    > directives described in styles above. Actually I would like to
    > discover some directive line "override:a ll"![/color]

    No such property exists.

    --
    David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is

    Comment

    • Grant Wagner

      #3
      Re: Overriding styles

      "David Dorward" <dorward@yahoo. com> wrote in message
      news:d02j12$ehj $1$8302bc10@new s.demon.co.uk.. .[color=blue]
      > Sergey Ilinsky wrote:
      >[color=green]
      >> How can i override all the styles being cascaded applied to some HTML
      >> element?[/color]
      >
      > By *explicitly* setting different styles.[/color]

      Or create a class for the attributes you want, then don't include that
      class on the elements for which you want the default behaviour. This
      keeps you from having to determine what the default CSS values are and
      setting a class with those styles.
      [color=blue][color=green]
      >> I would like to not have the inner DIV padding, margin and other
      >> directives described in styles above. Actually I would like to
      >> discover some directive line "override:a ll"![/color]
      >
      > No such property exists.[/color]

      Which is why I'd do it something like this:

      <style type="text/css">
      div.paddedWithM argin {
      padding: 10px; margin: 10px;
      }
      </style>
      <div>This will have the default padding and margin values</div>
      <div class="paddedWi thMargin">This will have your custom padding and
      margin values</div>

      Adding a class to every -div- on the page can be a bit cumbersome if you
      want every -div- to have the custom CSS style except for one. To fix
      that, you could use something like:

      <style type="text/css">
      div.paddedWithM argin div {
      padding: 10px; margin: 10px;
      }
      </style>
      <div>This will have the default padding and margin values</div>
      <div class="paddedWi thMargin">
      <div>This will have your custom padding and margin values</div>
      <div>This will have your custom padding and margin values</div>
      <div>This will have your custom padding and margin values</div>
      <div>This will have your custom padding and margin values</div>
      </div>

      Anyway, what does any of this have to do with JavaScript?

      --
      Grant Wagner <gwagner@agrico reunited.com>
      comp.lang.javas cript FAQ - http://jibbering.com/faq


      Comment

      Working...