Skip to main content
Deaf_Guy
Inspiring
January 25, 2018
Répondu

How to incorporate link CSS with an ID CSS?

I have a table set up and have the BG color and so forth ready but cannot figure out how to make a text link inside of the table have stylized link effects in it. Here is what I have. I thought that because I included the link styling in the #mm part it would work. Any help is appreciated thank you.

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Untitled Document</title>

<style>

#mm {

    color: #ffffff;

background-color: #1f4d81;

a:link {

    color: #ffffff;

text-decoration: none;

}

a:visited {

    color: #ffffff;

text-decoration: none;

}

a:hover {

    color: #ffffff;

text-decoration: underline;

}

a:active {

    color: #ffffff;

text-decoration: underline;

}

</style>

</head>

<body>

<br/>

<table width="100%" id="mm" border="0" cellspacing="20" cellpadding="20">

   <tbody>

      <tr>

         <td width="4%" align="center" valign="middle">

            <img width="76" height="69" src="mm-logo.png" alt=""/>

         </td>

  <td width="96%" align="left" valign="middle">Some white text here

            <a href="page.html" target="_blank" style="text-decoration: underline;">Click here to join the conversation</a></td>

      </tr>

   </tbody>

</table>

</body>

</html>

    Ce sujet a été fermé aux réponses.
    Meilleure réponse par Jon Fritz

    You're missing an ending } for your #mm id.

    #mm is the <div>

    a:whatever is written after (overwrites) and specifically targets the links.

    "#mm a:whatever" as a selector will probably get you where you want to be. (affecting only the links inside the <div id="mm">)

    Remove the inline css from the link, inline will (almost) always overwrite the external sheet or <head> css.

    If you want all the text to be white, and have an underline show up on :hover or while being clicked with :active (I think what you're going for?), this is how I would change your code...

    <!doctype html>

    <html>

    <head>

    <meta charset="utf-8">

    <title>Untitled Document</title>

    <style>

    #mm {

        color: #ffffff;

        background-color: #1f4d81;

    }

    #mm a {

        color: #ffffff;

        text-decoration: none;

    }

    #mm a:visited {

        text-decoration: none;

    }

    #mm a:hover {

        text-decoration: underline;

    }

    #mm a:active {

        text-decoration: underline;

    }

    </style>

    </head>

    <body>

      <br/>

      <table width="100%" id="mm" border="0" cellspacing="20" cellpadding="20">

        <tbody>

          <tr>

            <td width="4%" align="center" valign="middle"><img width="76" height="69" src="mm-logo.png" alt=""/></td>

            <td width="96%" align="left" valign="middle">Some white text here <a href="page.html">Click here to join the conversation</a></td>

          </tr>

        </tbody>

      </table>

    </body>

    </html>

    1 commentaire

    Jon Fritz
    Community Expert
    Jon FritzCommunity ExpertRéponse
    Community Expert
    January 25, 2018

    You're missing an ending } for your #mm id.

    #mm is the <div>

    a:whatever is written after (overwrites) and specifically targets the links.

    "#mm a:whatever" as a selector will probably get you where you want to be. (affecting only the links inside the <div id="mm">)

    Remove the inline css from the link, inline will (almost) always overwrite the external sheet or <head> css.

    If you want all the text to be white, and have an underline show up on :hover or while being clicked with :active (I think what you're going for?), this is how I would change your code...

    <!doctype html>

    <html>

    <head>

    <meta charset="utf-8">

    <title>Untitled Document</title>

    <style>

    #mm {

        color: #ffffff;

        background-color: #1f4d81;

    }

    #mm a {

        color: #ffffff;

        text-decoration: none;

    }

    #mm a:visited {

        text-decoration: none;

    }

    #mm a:hover {

        text-decoration: underline;

    }

    #mm a:active {

        text-decoration: underline;

    }

    </style>

    </head>

    <body>

      <br/>

      <table width="100%" id="mm" border="0" cellspacing="20" cellpadding="20">

        <tbody>

          <tr>

            <td width="4%" align="center" valign="middle"><img width="76" height="69" src="mm-logo.png" alt=""/></td>

            <td width="96%" align="left" valign="middle">Some white text here <a href="page.html">Click here to join the conversation</a></td>

          </tr>

        </tbody>

      </table>

    </body>

    </html>

    Deaf_Guy
    Deaf_GuyAuteur
    Inspiring
    January 25, 2018

    Really appreciate it thanks so much!