4 Replies Latest reply on Nov 13, 2008 7:52 AM by Nedward

    CSS link color problem

    Nedward Level 1
      Hi:

      On this page, in the "profiles" div, I would like the links to be black:
      http://www.curlytopdesign.com/testwebs/sunshine/grocery.com

      However, earlier in the site in "maincontent", I made the links red:
      http://www.curlytopdesign.com/testwebs/sunshine/index.com

      Unfortunately, the "profiles" links are coming out red. CSS is below. The footer is working correctly, independently. I have tried different labeling of the "profiles" links with no success -- any suggestions?

      Thx, Ned

      @charset "utf-8";
      body {
      font: 100% Verdana, Arial, Helvetica, sans-serif;
      margin: 5px 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
      padding: 0;
      text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
      color: #000000;
      font-size: 100%;
      background-color: #999999;
      background-position: center;
      }
      #container {
      width: 760px; /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
      background: #FEFEB1;
      margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
      border: 1px solid #FF0000;
      text-align: left; /* this overrides the text-align: center on the body element. */
      }
      #header {
      padding: 0; /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */
      background-image: url(../images/sunshine_header.jpg);
      background-repeat: no-repeat;
      background-position: center center;
      }
      #navcontainer {
      background: #FEFEB1;
      padding: 0 0 25px 80px;
      }
      #leftsidebar {
      float: left; /* since this element is floated, a width must be given */
      width: 150px; /* the actual width of this div, in standards-compliant browsers, or standards mode in Internet Explorer will include the padding and border in addition to the width */
      background: #FEFEB1; /* the background color will be displayed for the length of the content in the column, but no further */
      padding: 20px 10px 15px 20px; /* padding keeps the content of the div away from the edges */
      }
      #maincontent {
      margin: 20px 30px 20px 180px; /* the right and left margins on this div element creates the two outer columns on the sides of the page. No matter how much content the sidebar divs contain, the column space will remain. You can remove this margin if you want the #mainContent div's text to fill the sidebar spaces when the content in each sidebar ends. */
      padding: 0; /* remember that padding is the space inside the div box and margin is the space outside the div box */
      font-size: 85%;
      }
      #maincontent p {
      font-size: 90%;
      color: #000000;
      }
      #maincontent a, a:visited {
      color: #FF0000;
      text-decoration: underline;
      }
      #maincontent a:hover {
      text-decoration: none;
      }
      .mainimage {
      border: thin solid #FFFF00;
      }
      .profiles {
      color: #000000;
      width: 500px;
      text-align: left;
      margin: 15px 0;
      border: thin solid #FF0000;
      padding: 5px;
      font-size: 90%;
      }
      .profiles a, a:visited {
      color: #000000;
      font-weight: bold;
      text-decoration: underline;
      }
      .profiles a:hover {
      text-decoration: none;
      }
      .caption {
      font-size: 66%;
      font-style: italic;
      }
      #footer {
      padding: 5px;
      background-color: #3433CC;
      border-top-width: thick;
      border-top-style: solid;
      border-top-color: #FFFF00;
      color: #FFFFFF;
      font-size: 66%;
      text-align: center;
      line-height: 2em;
      }
      #footer a, a:visited {
      color: #FFFFFF;
      font-weight: normal;
      text-decoration: underline;
      }
      #footer a:hover {
      text-decoration: none;
      }
      #footer p {
      margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
      padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
      font-size: 75%;
      text-align: center;
      color: #FFFFFF;
      }
      .fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
      float: right;
      margin-left: 8px;
      }
      .fltlft { /* this class can be used to float an element left in your page */
      float: left;
      margin-right: 8px;
      }
      .clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
      clear:both;
      height:0;
      font-size: 1px;
      line-height: 0px;
      }
      h1 {
      font-size: 125%;
      font-weight: bold;
      color: #4848D0;
      }
      h2 {
      font-size: 110%;
      font-weight: bold;
      color: #4848D0;
      }
      h3 {
      font-size: 100%;
      font-weight: bold;
      color: #000000;
      font-style:italic;
      }
        • 1. Re: CSS link color problem
          Level 7
          I can't get to your page at the link provided, it says NOT FOUND but try:



          #maincontent .profiles a, a:visited {
          color: #000000;
          font-weight: bold;
          text-decoration: underline;
          }


          #maincontent .profiles a:hover {
          text-decoration: none;
          }



          It might be a question of css specifity, the id overriding the class style.




          Nedward wrote:
          > Hi:
          >
          > On this page, in the "profiles" div, I would like the links to be black:
          > http://www.curlytopdesign.com/testwebs/sunshine/grocery.com
          >
          > However, earlier in the site in "maincontent", I made the links red:
          > http://www.curlytopdesign.com/testwebs/sunshine/index.com
          >
          > Unfortunately, the "profiles" links are coming out red. CSS is below. The
          > footer is working correctly, independently. I have tried different labeling of
          > the "profiles" links with no success -- any suggestions?
          >
          > Thx, Ned
          >
          > @charset "utf-8";
          > body {
          > font: 100% Verdana, Arial, Helvetica, sans-serif;
          > margin: 5px 0; /* it's good practice to zero the margin and padding of the
          > body element to account for differing browser defaults */
          > padding: 0;
          > text-align: center; /* this centers the container in IE 5* browsers. The text
          > is then set to the left aligned default in the #container selector */
          > color: #000000;
          > font-size: 100%;
          > background-color: #999999;
          > background-position: center;
          > }
          > #container {
          > width: 760px; /* using 20px less than a full 800px width allows for browser
          > chrome and avoids a horizontal scroll bar */
          > background: #FEFEB1;
          > margin: 0 auto; /* the auto margins (in conjunction with a width) center the
          > page */
          > border: 1px solid #FF0000;
          > text-align: left; /* this overrides the text-align: center on the body
          > element. */
          > }
          > #header {
          > padding: 0; /* this padding matches the left alignment of the elements in
          > the divs that appear beneath it. If an image is used in the #header instead of
          > text, you may want to remove the padding. */
          > background-image: url(../images/sunshine_header.jpg);
          > background-repeat: no-repeat;
          > background-position: center center;
          > }
          > #navcontainer {
          > background: #FEFEB1;
          > padding: 0 0 25px 80px;
          > }
          > #leftsidebar {
          > float: left; /* since this element is floated, a width must be given */
          > width: 150px; /* the actual width of this div, in standards-compliant
          > browsers, or standards mode in Internet Explorer will include the padding and
          > border in addition to the width */
          > background: #FEFEB1; /* the background color will be displayed for the length
          > of the content in the column, but no further */
          > padding: 20px 10px 15px 20px; /* padding keeps the content of the div away
          > from the edges */
          > }
          > #maincontent {
          > margin: 20px 30px 20px 180px; /* the right and left margins on this div
          > element creates the two outer columns on the sides of the page. No matter how
          > much content the sidebar divs contain, the column space will remain. You can
          > remove this margin if you want the #mainContent div's text to fill the sidebar
          > spaces when the content in each sidebar ends. */
          > padding: 0; /* remember that padding is the space inside the div box and
          > margin is the space outside the div box */
          > font-size: 85%;
          > }
          > #maincontent p {
          > font-size: 90%;
          > color: #000000;
          > }
          > #maincontent a, a:visited {
          > color: #FF0000;
          > text-decoration: underline;
          > }
          > #maincontent a:hover {
          > text-decoration: none;
          > }
          > .mainimage {
          > border: thin solid #FFFF00;
          > }
          > .profiles {
          > color: #000000;
          > width: 500px;
          > text-align: left;
          > margin: 15px 0;
          > border: thin solid #FF0000;
          > padding: 5px;
          > font-size: 90%;
          > }
          > .profiles a, a:visited {
          > color: #000000;
          > font-weight: bold;
          > text-decoration: underline;
          > }
          > .profiles a:hover {
          > text-decoration: none;
          > }
          > .caption {
          > font-size: 66%;
          > font-style: italic;
          > }
          > #footer {
          > padding: 5px;
          > background-color: #3433CC;
          > border-top-width: thick;
          > border-top-style: solid;
          > border-top-color: #FFFF00;
          > color: #FFFFFF;
          > font-size: 66%;
          > text-align: center;
          > line-height: 2em;
          > }
          > #footer a, a:visited {
          > color: #FFFFFF;
          > font-weight: normal;
          > text-decoration: underline;
          > }
          > #footer a:hover {
          > text-decoration: none;
          > }
          > #footer p {
          > margin: 0; /* zeroing the margins of the first element in the footer will
          > avoid the possibility of margin collapse - a space between divs */
          > padding: 10px 0; /* padding on this element will create space, just as the
          > the margin would have, without the margin collapse issue */
          > font-size: 75%;
          > text-align: center;
          > color: #FFFFFF;
          > }
          > .fltrt { /* this class can be used to float an element right in your page. The
          > floated element must precede the element it should be next to on the page. */
          > float: right;
          > margin-left: 8px;
          > }
          > .fltlft { /* this class can be used to float an element left in your page */
          > float: left;
          > margin-right: 8px;
          > }
          > .clearfloat { /* this class should be placed on a div or break element and
          > should be the final element before the close of a container that should fully
          > contain a float */
          > clear:both;
          > height:0;
          > font-size: 1px;
          > line-height: 0px;
          > }
          > h1 {
          > font-size: 125%;
          > font-weight: bold;
          > color: #4848D0;
          > }
          > h2 {
          > font-size: 110%;
          > font-weight: bold;
          > color: #4848D0;
          > }
          > h3 {
          > font-size: 100%;
          > font-weight: bold;
          > color: #000000;
          > font-style:italic;
          > }
          >
          • 2. Re: CSS link color problem
            malcster2 Level 1
            where is the identifier for the profil div. you have a class of .profile, but no div.

            if you did, you could have
            #profile a
            {
            text-color:000000;
            }

            or

            #profile.profile a
            {
            text-color:000000;
            }
            • 3. Re: CSS link color problem
              Level 7
              malcster2 wrote:
              > where is the identifier for the profil div. you have a class of .profile, but
              > no div.

              Sure theres a lot of <divs> with the class profile: (Ive now got to the
              code by taking .com off the end of the link.


              <div class="profiles">
              <strong>KRISTY DESJARDINS: Eureka</strong><br /><br />
              <strong>Territory served:</strong> Mendocino and Humboldt
              Counties; Redding; Chico; Sacramento Valley south to Modesto<br />
              <!-- end profile div --></div>


              It was a specifity issue as outlined in my original post, including the
              id #maincontent before the class, as below sets this right.


              #maincontent .profiles a, a:visited {
              color: #000000;
              font-weight: bold;
              text-decoration: underline;
              }


              #maincontent .profiles a:hover {
              text-decoration: none;
              }











              >
              > if you did, you could have
              > #profile a
              > {
              > text-color:000000;
              > }
              >
              > or
              >
              > #profile.profile a
              > {
              > text-color:000000;
              > }
              >
              >
              • 4. Re: CSS link color problem
                Nedward Level 1
                Hi:

                That's what I get for working late (.com instead of .html in link)!

                I had experimented with adding #maincontent before .profiles a, but it lacked the necessary space in between. Much better now -- thanks!