ID Selector problem

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

    ID Selector problem

    Hi,
    I am having some grieve with the following part of my CSS, basically
    when using a composite selector using an ID as the first element the
    it doesn't display the expected results. Am I doing something
    incorrect? For example my CSS goes something like this:

    #leftnavbar a:link {
    color: #333;
    text-decoration: none;
    }
    #leftnavbar a:visited {
    color: #FFF;
    }

    #topnavbar a:link {
    color: #000;
    }
    #topnavbar a:visited {
    color: #FFF;
    }

    However, for some reason both within dreamweaver and Explorer all the
    links are using the #topnavbar colours? i.e. the #topnavbar selector
    is overriding the #leftnavbar selector, even standard links in the
    general "body" of the document are being changed to the #topnavbar
    colours when they should stay as links normally would. What am I doing
    wrong?

    Thanks

    Zane
  • Matthias Gutfeldt

    #2
    Re: ID Selector problem

    Zane wrote:[color=blue]
    > #leftnavbar a:link {
    > color: #333;
    > text-decoration: none;
    > }
    > #leftnavbar a:visited {
    > color: #FFF;
    > }
    >
    > #topnavbar a:link {
    > color: #000;
    > }
    > #topnavbar a:visited {
    > color: #FFF;
    > }
    >
    > However, for some reason both within dreamweaver and Explorer all the
    > links are using the #topnavbar colours? i.e. the #topnavbar selector
    > is overriding the #leftnavbar selector, even standard links in the
    > general "body" of the document are being changed to the #topnavbar
    > colours when they should stay as links normally would. What am I doing
    > wrong?[/color]

    The CSS looks OK. So either you are hallucinating, or there's a problem
    that is not apparent from your code snippet, either in your HTML code or
    the stylesheet. Give us the URL so we can see the whole thing in context!


    Matthias

    Comment

    • Steve Pugh

      #3
      Re: ID Selector problem

      zane_cahill@hot mail.com (Zane) wrote:
      [color=blue]
      >#leftnavbar a:link {
      > color: #333;
      > text-decoration: none;
      > }
      >#leftnavbar a:visited {
      > color: #FFF;
      > }
      >
      >#topnavbar a:link {
      > color: #000;
      > }
      >#topnavbar a:visited {
      > color: #FFF;
      > }
      >
      >However, for some reason both within dreamweaver and Explorer all the
      >links are using the #topnavbar colours? i.e. the #topnavbar selector
      >is overriding the #leftnavbar selector, even standard links in the
      >general "body" of the document are being changed to the #topnavbar
      >colours when they should stay as links normally would. What am I doing
      >wrong?[/color]

      The CSS looks okay, (though you really should set a background colour
      whenever you set a foreground colour). So the problem is probably with
      the HTML. Post a URL.

      Steve

      --
      "My theories appal you, my heresies outrage you,
      I never answer letters and you don't like my tie." - The Doctor

      Steve Pugh <steve@pugh.net > <http://steve.pugh.net/>

      Comment

      • Jim Dabell

        #4
        Re: ID Selector problem

        Zane wrote:
        [color=blue]
        > Hi,
        > I am having some grieve with the following part of my CSS, basically
        > when using a composite selector using an ID as the first element the
        > it doesn't display the expected results. Am I doing something
        > incorrect? For example my CSS goes something like this:
        >
        > #leftnavbar a:link {
        > color: #333;
        > text-decoration: none;
        > }[/color]
        [snip][color=blue]
        > However, for some reason both within dreamweaver and Explorer all the
        > links are using the #topnavbar colours? i.e. the #topnavbar selector
        > is overriding the #leftnavbar selector, even standard links in the
        > general "body" of the document are being changed to the #topnavbar
        > colours when they should stay as links normally would. What am I doing
        > wrong?[/color]

        There's nothing obviously wrong. I suspect there's a problem with your HTML
        (perhaps you aren't closing the #topnavbar element in the right place?).
        Validate your HTML and if you still have trouble, give a URL to a testcase.


        --
        Jim Dabell

        Comment

        • Evertjan.

          #5
          Re: ID Selector problem

          Zane wrote on 13 aug 2003 in comp.infosystem s.www.authoring.stylesheets:
          [color=blue]
          > However, for some reason both within dreamweaver and Explorer all the
          > links are using the #topnavbar colours? i.e. the #topnavbar selector
          > is overriding the #leftnavbar selector, even standard links in the
          > general "body" of the document are being changed to the #topnavbar
          > colours when they should stay as links normally would. What am I doing
          > wrong?
          >[/color]

          There is a difference between:

          #topnavbar a:hover { color: #0f0; }

          and

          a#topnavbar:hov er { color: #0f0; }

          the first <a > expects a parent with the id topnavbar

          <div id=topnavbar><a href=''>...

          the second <a > expects to be the owner of the id topnavbar

          <a id=topnavbar href=''>...



          --
          Evertjan.
          The Netherlands.
          (Please change the x'es to dots in my emailaddress)

          Comment

          Working...