Changing link properties for "current" entry on menu

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

    Changing link properties for "current" entry on menu

    Within the menu for my site, I have inserted 'class="current "' within
    the link for the current page. So the link looks somthing link:

    <li><a href="index.php " class="current" >Home</a></li>

    The css for formatting the menu links is:

    #menu a:hover {
    background-color: #E00080;
    color: white;
    }

    #menu a:active {
    background-color: #E00080;
    color: white;
    }

    #menu li li a {
    display: block;
    color: white;
    background-color: #C00080;
    width: 100%;
    padding: 0.5em 0.5em 0.5em 2em;
    text-decoration: none;
    border-bottom: 1px solid #fff;
    font-weight: normal;
    font-size: 75%;
    }

    and for the "current" link:

    ..current {
    background-color: red;
    }

    But the formatting does not show up.

    Does anyone have any idea what I'm doing wrong? If you would like to
    look at the complete site, go to:



    Thank you for your help,

    Don

    PS If you have any suggestions, please feel free to offer them. The
    general color scheme is non-negotiable though (it's for my daughter
    after all). Though, I might work up some alternate stylesheets.
  • David Dorward

    #2
    Re: Changing link properties for &quot;current&q uot; entry on menu

    Don G wrote:
    [color=blue]
    > #menu a:hover { background-color: #E00080; }
    > and for the "current" link:
    > .current { background-color: red; }
    > But the formatting does not show up.[/color]

    Most specific selector wins. .current is less specific then #menu a:hover.



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

    Comment

    • Christoph Paeper

      #3
      Re: Changing link properties for &quot;current&q uot; entry on menu

      *Don G* <mail4dag@yahoo .com>:[color=blue]
      >
      > Within the menu for my site, I have inserted 'class="current "' within
      > the link for the current page.[/color]

      Why? Why would anyone want to go to the current page? It's just confusing
      people.
      [color=blue]
      > <li><a href="index.php " class="current" >Home</a></li>[/color]

      Why "index.php" ? "./" or "/" seem logical.

      <li><a>Home</a></li>

      #menu a {
      background-color: red;
      color: white;
      }
      #menu a:link, #menu a:visited {
      background-color: #C00080;
      }
      [color=blue]
      > #menu a:hover {
      > background-color: #E00080;
      > }
      > #menu a:active {
      > background-color: #E00080;
      > }[/color]

      Or something like that.

      --
      It's so simple to be wise. Just think of
      something stupid to say and say the opposite.

      Comment

      • Don G

        #4
        Re: Changing link properties for &quot;current&q uot; entry on menu

        > Why? Why would anyone want to go to the current page? It's just[color=blue]
        > confusing people.[/color]

        Why, well, I don't want change the menu for each page removing the link
        to the current page, but I would like to differentiate the link for the
        current page from the rest of the links so the user can know which page
        they are on by looking at the menu.
        [color=blue]
        > Why "index.php" ? "./" or "/" seem logical.[/color]

        Why not? Does it really make a difference? I did it for consistency.
        The rest of the links in the menu specify a filename so I specified the
        link to index.php as well. Is there a good reason to not do it?
        [color=blue]
        > <li><a>Home</a></li>
        >
        > #menu a {
        > background-color: red;
        > color: white;
        > }
        > #menu a:link, #menu a:visited {
        > background-color: #C00080;
        > }
        >[color=green]
        >> #menu a:hover {
        >> background-color: #E00080;
        >> }
        >> #menu a:active {
        >> background-color: #E00080;
        >> }[/color]
        >
        >
        > Or something like that.
        >[/color]

        I'm including the menu using PHP to help with site management, and it is
        easy to add 'class="current "'. However, I am not aware of how I might
        remove the href for the link to the current page, which is why I asked
        the question I asked. So, do you know of a way to remove the href using
        PHP?

        Thanks,

        Don

        Comment

        • Don G

          #5
          Re: Changing link properties for &quot;current&q uot; entry on menu

          >>#menu a:hover { background-color: #E00080; }[color=blue][color=green]
          >>and for the "current" link:
          >>.current { background-color: red; }
          >>But the formatting does not show up.[/color]
          >
          >
          > Most specific selector wins. .current is less specific then #menu a:hover.[/color]

          Ah, interesting. I was not aware of this. I was thinking that since it
          was later in the cascade, then it would override. So, how do I fix my
          problem then? I tried making "current" more specific by switching it to:

          #current ul li a { background-color: red; }
          #current ul li a:hover { background-color: red; }

          But I still got the same result. My understanding of the link you sent
          is that what I have above is more specific than what I had originally
          because of the added element names.

          Ah ha! I've got it now.

          #menu ul li a.current { background-color: red; }
          #menu ul li a.current:hover { background-color: red; }

          Does what I want it to do! I don't know if everything I've specified is
          necessary, but it works. I'll play with it some more to see what happens.

          Thanks a bundle!

          Don

          Comment

          • Lauri Raittila

            #6
            Re: Changing link properties for &quot;current&q uot; entry on menu

            in comp.infosystem s.www.authoring.stylesheets, Don G wrote:[color=blue][color=green]
            > > Why? Why would anyone want to go to the current page? It's just
            > > confusing people.[/color]
            >
            > Why, well, I don't want change the menu for each page removing the link
            > to the current page,[/color]

            Why? that is usually best approach. I can't think any reason why person
            would like to go to same page he already is, especially using menu.
            [color=blue]
            > but I would like to differentiate the link for the
            > current page from the rest of the links so the user can know which page
            > they are on by looking at the menu.
            >[color=green]
            > > Why "index.php" ? "./" or "/" seem logical.[/color]
            >
            > Why not? Does it really make a difference?[/color]

            Sure it makes. if you are in page

            and there is link to
            http://www.example.org/foo/index.php (if you use index.php)
            it surely looks different that that link to
            http://www.example.org/foo/ (if you use ./)
            [color=blue]
            > I did it for consistency.[/color]

            It is less consistant, as you use different URL for same page. If your
            server is some rare case that never shows / on end but redirects to
            /index.xxx, then it might be consistant.
            [color=blue]
            > The rest of the links in the menu specify a filename so I specified the
            > link to index.php as well. Is there a good reason to not do it?[/color]
            [color=blue]
            > I'm including the menu using PHP to help with site management, and it is
            > easy to add 'class="current "'. However, I am not aware of how I might
            > remove the href for the link to the current page, which is why I asked
            > the question I asked. So, do you know of a way to remove the href using
            > PHP?[/color]

            No, I don't, but I suspect it is just as easy.

            --
            Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
            Utrecht, NL.

            Comment

            • Don G

              #7
              Re: Changing link properties for &quot;current&q uot; entry on menu

              > Why? that is usually best approach. I can't think any reason why person[color=blue]
              > would like to go to same page he already is, especially using menu.[/color]

              No, but a person is able to look at the menu and see where they are. I
              was under the impression that it is a good idea to indicate on the menu
              which page is currently being displayed.
              [color=blue]
              > Sure it makes. if you are in page
              > http://www.example.org/foo/
              > and there is link to
              > http://www.example.org/foo/index.php (if you use index.php)
              > it surely looks different that that link to
              > http://www.example.org/foo/ (if you use ./)[/color]

              I suppose you are right, but I think that it is clear from the menu,
              especially with highlighting the current page, that it is a link to the
              current page.
              [color=blue][color=green]
              >>The rest of the links in the menu specify a filename so I specified the
              >>link to index.php as well. Is there a good reason to not do it?[/color]
              >
              >[color=green]
              >>I'm including the menu using PHP to help with site management, and it is
              >>easy to add 'class="current "'. However, I am not aware of how I might
              >>remove the href for the link to the current page, which is why I asked
              >>the question I asked. So, do you know of a way to remove the href using
              >>PHP?[/color]
              >
              >
              > No, I don't, but I suspect it is just as easy.[/color]

              I just thought of another potential snag, or maybe another bad design
              choice on my part. I am using a multi-tier menu whose HTML is similar
              to this:

              <div id="menu">
              <ul>
              <li>
              <a href="index.htm l">Home</a>
              </li>
              <li>
              <a>Group A</a>
              <ul>
              <li>
              <a href="itema1.ht ml">Item A1</a>
              </li>
              <li>
              <a href="itema2.ht ml">Item A2</a>
              </li>
              <li>
              <a href="itema3.ht ml">Item A3</a>
              </li>
              </ul>
              </li>
              <a>Group B</a>
              <ul>
              <li>
              <a href="itemb1.ht ml">Item B1</a>
              </li>
              <li>
              <a href="itemb2.ht ml">Item B2</a>
              </li>
              <li>
              <a href="itemb3.ht ml">Item B3</a>
              </li>
              </ul>
              </ul>
              </div>

              I did this because I wanted all of the top tier items to have the same
              appearance, regardless of whether they were a link. So, if I just
              remove the href, then the current page will not be differentiated. I
              guess there are other ways of doing what I have done, but it would
              involve rethinking how I have done the CSS for my menu. I based what I
              did off of an example I found, not realizing the potential problems.

              Does anyone have a link to suggested best practices for menus?

              Thanks,

              Don

              Comment

              • Lauri Raittila

                #8
                Re: Changing link properties for &quot;current&q uot; entry on menu

                in comp.infosystem s.www.authoring.stylesheets, Don G wrote:[color=blue][color=green]
                > > Why? that is usually best approach. I can't think any reason why person
                > > would like to go to same page he already is, especially using menu.[/color]
                >
                > No, but a person is able to look at the menu and see where they are. I
                > was under the impression that it is a good idea to indicate on the menu
                > which page is currently being displayed.[/color]

                Sure, but it is not good idea to have link there.
                [color=blue][color=green]
                > > Sure it makes. if you are in page
                > > http://www.example.org/foo/
                > > and there is link to
                > > http://www.example.org/foo/index.php (if you use index.php)
                > > it surely looks different that that link to
                > > http://www.example.org/foo/ (if you use ./)[/color]
                >
                > I suppose you are right, but I think that it is clear from the menu,
                > especially with highlighting the current page, that it is a link to the
                > current page.[/color]

                No, it is not necessarily so. What is user uses some toher means to
                access that link? Things like links panel in Opera 7? Or if user has CSS
                disabled? And it might be not show up as visited link if you use
                different URL (in fact, it could be different page, so that is no
                wonder).
                [color=blue][color=green][color=darkred]
                > >>The rest of the links in the menu specify a filename so I specified the
                > >>link to index.php as well. Is there a good reason to not do it?[/color][/color][/color]

                Yes. 2 URLs for same page is not good.
                [color=blue]
                > I just thought of another potential snag, or maybe another bad design
                > choice on my part. I am using a multi-tier menu whose HTML is similar
                > to this:
                >
                > <a>Group B</a>[/color]

                [color=blue]
                > I did this because I wanted all of the top tier items to have the same
                > appearance, regardless of whether they were a link. So, if I just
                > remove the href, then the current page will not be differentiated.[/color]

                Well, you need to differentiate it. Anyway, I think your markup should
                make difference between headings and links.
                [color=blue]
                > Does anyone have a link to suggested best practices for menus?[/color]

                Best practice is not to include complex menu on every page...

                --
                Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
                Utrecht, NL.

                Comment

                • Don G

                  #9
                  Re: Changing link properties for &quot;current&q uot; entry on menu

                  > Best practice is not to include complex menu on every page...

                  It really isn't all that complex of a menu, or at least I don't think
                  so. It sounds more complex that it really is.

                  So, what is a better way to do it? It seems to me that most pages do
                  what I am talking about (though they may be doing it better than I am).
                  I realize that that isn't necessarily an indication that it is a good
                  thing, but it seems to work rather well.

                  Do you think it would be better to have a link on each page that takes
                  the reader back to the index?

                  Thanks,

                  Don

                  Comment

                  • Lauri Raittila

                    #10
                    Re: Changing link properties for &quot;current&q uot; entry on menu

                    in comp.infosystem s.www.authoring.stylesheets, Don G wrote:[color=blue][color=green]
                    > > Best practice is not to include complex menu on every page...[/color]
                    >
                    > It really isn't all that complex of a menu, or at least I don't think
                    > so. It sounds more complex that it really is.
                    >
                    > So, what is a better way to do it? It seems to me that most pages do
                    > what I am talking about (though they may be doing it better than I am).[/color]

                    Most pages do things bad way... To know what is good for your page, it
                    would require knowing your page.
                    [color=blue]
                    > I realize that that isn't necessarily an indication that it is a good
                    > thing, but it seems to work rather well.[/color]

                    It is not necessarily very bad thing.
                    [color=blue]
                    > Do you think it would be better to have a link on each page that takes
                    > the reader back to the index?[/color]

                    Likely.

                    --
                    Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
                    Utrecht, NL.

                    Comment

                    • Don G

                      #11
                      Re: Changing link properties for &quot;current&q uot; entry on menu

                      > Most pages do things bad way... To know what is good for your page, it[color=blue]
                      > would require knowing your page.[/color]

                      Feel free to take a look and give me any comments you might have.

                      holly.sillyfami ly.org

                      Thank you for your help,

                      Don

                      Comment

                      • Lauri Raittila

                        #12
                        Re: Changing link properties for &quot;current&q uot; entry on menu

                        in comp.infosystem s.www.authoring.stylesheets, Don G wrote:[color=blue][color=green]
                        > > Most pages do things bad way... To know what is good for your page, it
                        > > would require knowing your page.[/color]
                        >
                        > Feel free to take a look and give me any comments you might have.
                        >
                        > holly.sillyfami ly.org
                        >
                        > Thank you for your help,[/color]

                        You will have confusingly complex menu in 6 months, if you add one item
                        each month. And already, your manu is taking space that could be used for
                        something else, for example to put next/previous links available without
                        scrolling.

                        It is confusing that I can't click Pre-Birth but can click Home, they
                        look and feel same.

                        --
                        Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
                        Utrecht, NL.

                        Comment

                        • Don G

                          #13
                          Re: Changing link properties for &quot;current&q uot; entry on menu

                          > You will have confusingly complex menu in 6 months, if you add one item[color=blue]
                          > each month.[/color]

                          Why do you say it is complex? It is but a simple list. Aside from the
                          fact that some of the items are not links, how is it confusing?
                          [color=blue]
                          > And already, your manu is taking space that could be used for
                          > something else, for example to put next/previous links available without
                          > scrolling.[/color]

                          Yes, that would be nice, but I thought it would be better to always be
                          able to jump to any other page without having to go back. I guess that
                          is why is at least part of why you feel it is complex.
                          [color=blue]
                          > It is confusing that I can't click Pre-Birth but can click Home, they
                          > look and feel same.[/color]

                          You have a good point here. What I think I will do now is move most of
                          the formatting from the link tag to the list item tags, but keep the
                          hover on the links. This will help differentiate links from non-links.
                          Do you think that would eliminate the confusion or should I do
                          something else to help differentiate the non-links?

                          Thank you for your input,

                          Don

                          Comment

                          • Lauri Raittila

                            #14
                            Re: Changing link properties for &quot;current&q uot; entry on menu

                            in comp.infosystem s.www.authoring.stylesheets, Don G wrote:[color=blue][color=green]
                            > > You will have confusingly complex menu in 6 months, if you add one item
                            > > each month.[/color]
                            >
                            > Why do you say it is complex? It is but a simple list. Aside from the
                            > fact that some of the items are not links, how is it confusing?[/color]

                            Hard to tell what is confusing, if the part that is confusing is not to
                            be taken account. It is 2 levels, but not consistant. It is not clear
                            that it is 2 levels, and especially it is not clear that home is link and
                            the others are headings.
                            [color=blue]
                            > Yes, that would be nice, but I thought it would be better to always be
                            > able to jump to any other page without having to go back.[/color]

                            So, you are assumimg that your images are so uninteresting, that
                            almost nobody bothers to look at them? I don't think you are wrong
                            here... but your mother is most likely bigger target for this page than
                            thousand ciwas readers...
                            [color=blue][color=green]
                            > > It is confusing that I can't click Pre-Birth but can click Home, they
                            > > look and feel same.[/color]
                            >
                            > You have a good point here. What I think I will do now is move most of
                            > the formatting from the link tag to the list item tags, but keep the
                            > hover on the links. This will help differentiate links from non-links.[/color]

                            But it is not perfect. They should not look same.
                            [color=blue]
                            > Do you think that would eliminate the confusion or should I do
                            > something else to help differentiate the non-links?[/color]

                            You need to make links look more links and text look more passive. It
                            doesn't help much to make them look different, if it is still unclear
                            which is link and which is text. There is convention that blue,
                            underlined text is link. That is best way to provide links today.

                            --
                            Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
                            Utrecht, NL.

                            Comment

                            • Don G

                              #15
                              Re: Changing link properties for &quot;current&q uot; entry on menu

                              > So, you are assumimg that your images are so uninteresting, that[color=blue]
                              > almost nobody bothers to look at them? I don't think you are wrong
                              > here...[/color]

                              There is no reason to be rude. I appologize for wasting your time by
                              asking for your advice on this learning project.

                              Good day,

                              Don

                              Comment

                              Working...