How do I not underline an element in a link?Text decoration for link and span inside this linkHow to...

Does this property characterize the odd primes?

How many copper coins fit inside a cubic foot?

Why are "square law" devices important?

Is it common to refer to someone as "Prof. Dr. [LastName]"?

Why write a book when there's a movie in my head?

Coworker is trying to get me to sign his petition to run for office. How to decline politely?

How can changes in personality/values of a person who turned into a vampire be explained?

Why is Shelob considered evil?

Multiplying elements of a list

Why does this quiz question say that protons and electrons do not combine to form neutrons?

How do I not underline an element in a link?

How can I differentiate duration vs starting time

Can I do anything else with aspersions other than cast them?

Why are `&array` and `array` pointing to the same address?

Is layered encryption more secure than long passwords?

80-bit collision resistence because of 80-bit x87 registers?

Can I combine Divination spells with Arcane Eye?

Is it possible to detect 100% of SQLi with a simple regex?

Why Doesn't It Completely Uninstall?

What does "don't have a baby" imply or mean in this sentence?

What did Putin say about a US deep state in his state-of-the-nation speech; what has he said in the past?

Why do we divide Permutations to get to Combinations?

Buying a "Used" Router

How to play songs that contain one guitar when we have two or more guitarists?



How do I not underline an element in a link?


Text decoration for link and span inside this linkHow to horizontally center a <div>?Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?How do I give text or an image a transparent background using CSS?How to disable text selection highlighting?How to check whether a checkbox is checked in jQuery?How to move an element into another element?How to make a div 100% height of the browser window?How to create an HTML button that acts like a link?How to disable resizable property of textarea?How do I vertically center text with CSS?













7















I am trying to underline the link except for the #myspan element, which I do not want underlined under any circumstance. I'd like to also change #myspan's color. The rules don't seem to apply to it. If I reverse the order and not underline the "a" but underline #myspan it seems to apply the rules. I've seen Text decoration for link and span inside this link to no avail.






    a {
text-decoration: underline;
}

a #myspan {
color: black;
text-decoration: none;
}

a:active #myspan {
color: grey;
text-decoration: none;
}

a:visited #myspan {
color: yellow;
text-decoration: none;
}

a:hover #myspan {
color: red;
text-decoration: none;
}

  <a href="#">A link <span id="myspan">some additional information</span></a>












share|improve this question





























    7















    I am trying to underline the link except for the #myspan element, which I do not want underlined under any circumstance. I'd like to also change #myspan's color. The rules don't seem to apply to it. If I reverse the order and not underline the "a" but underline #myspan it seems to apply the rules. I've seen Text decoration for link and span inside this link to no avail.






        a {
    text-decoration: underline;
    }

    a #myspan {
    color: black;
    text-decoration: none;
    }

    a:active #myspan {
    color: grey;
    text-decoration: none;
    }

    a:visited #myspan {
    color: yellow;
    text-decoration: none;
    }

    a:hover #myspan {
    color: red;
    text-decoration: none;
    }

      <a href="#">A link <span id="myspan">some additional information</span></a>












    share|improve this question



























      7












      7








      7


      1






      I am trying to underline the link except for the #myspan element, which I do not want underlined under any circumstance. I'd like to also change #myspan's color. The rules don't seem to apply to it. If I reverse the order and not underline the "a" but underline #myspan it seems to apply the rules. I've seen Text decoration for link and span inside this link to no avail.






          a {
      text-decoration: underline;
      }

      a #myspan {
      color: black;
      text-decoration: none;
      }

      a:active #myspan {
      color: grey;
      text-decoration: none;
      }

      a:visited #myspan {
      color: yellow;
      text-decoration: none;
      }

      a:hover #myspan {
      color: red;
      text-decoration: none;
      }

        <a href="#">A link <span id="myspan">some additional information</span></a>












      share|improve this question
















      I am trying to underline the link except for the #myspan element, which I do not want underlined under any circumstance. I'd like to also change #myspan's color. The rules don't seem to apply to it. If I reverse the order and not underline the "a" but underline #myspan it seems to apply the rules. I've seen Text decoration for link and span inside this link to no avail.






          a {
      text-decoration: underline;
      }

      a #myspan {
      color: black;
      text-decoration: none;
      }

      a:active #myspan {
      color: grey;
      text-decoration: none;
      }

      a:visited #myspan {
      color: yellow;
      text-decoration: none;
      }

      a:hover #myspan {
      color: red;
      text-decoration: none;
      }

        <a href="#">A link <span id="myspan">some additional information</span></a>








          a {
      text-decoration: underline;
      }

      a #myspan {
      color: black;
      text-decoration: none;
      }

      a:active #myspan {
      color: grey;
      text-decoration: none;
      }

      a:visited #myspan {
      color: yellow;
      text-decoration: none;
      }

      a:hover #myspan {
      color: red;
      text-decoration: none;
      }

        <a href="#">A link <span id="myspan">some additional information</span></a>





          a {
      text-decoration: underline;
      }

      a #myspan {
      color: black;
      text-decoration: none;
      }

      a:active #myspan {
      color: grey;
      text-decoration: none;
      }

      a:visited #myspan {
      color: yellow;
      text-decoration: none;
      }

      a:hover #myspan {
      color: red;
      text-decoration: none;
      }

        <a href="#">A link <span id="myspan">some additional information</span></a>






      html css






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 4 hours ago









      soulshined

      5,03642248




      5,03642248










      asked 4 hours ago









      Marissa LevyMarissa Levy

      2721652103




      2721652103
























          3 Answers
          3






          active

          oldest

          votes


















          6














          Make the element to be inline-block and it won't get affected by the underline:






          a {
          text-decoration: underline;
          }

          a #myspan {
          color: black;
          display:inline-block;
          }

          a:active #myspan {
          color: grey;
          }

          a:visited #myspan {
          color: yellow;
          }

          a:hover #myspan {
          color: red;
          }

          <a href="#">A link <span id="myspan">some additional information</span></a>






          Note that text decorations are not propagated to floating and absolutely positioned descendants, nor to the contents of atomic inline-level descendants such as inline blocks and inline tables. ref






          To remove the small space between text and span you can get rid of the whitespace and use a small margin:






          a {
          text-decoration: underline;
          }

          a #myspan {
          color: black;
          display:inline-block;
          margin-left:4px;
          }


          a:active #myspan {
          color: grey;
          }

          a:visited #myspan {
          color: yellow;
          }

          a:hover #myspan {
          color: red;
          }

          <a href="#">A link<span id="myspan">some additional information</span></a>








          share|improve this answer





















          • 1





            just learned something new. +1 Never had a reason to know this before today though.

            – soulshined
            4 hours ago



















          3














          I made a:hover #myspan, a:hover






          a {
          text-decoration: underline;
          }

          a #myspan {
          color: black;
          text-decoration: none;
          }

          a:active #myspan {
          color: grey;
          text-decoration: none;
          }

          a:visited #myspan {
          color: yellow;
          text-decoration: none;
          }

          a:hover #myspan, a:hover {
          color: red;
          text-decoration: none;
          }

          <a href="#">A link <span id="myspan">some additional information</span></a>








          share|improve this answer
























          • dont think OP wants the span underlined under any conditions. underline the link except for the #myspan element

            – soulshined
            4 hours ago













          • oops. The answer is given below. I misunderstood.

            – Dogukan Cavus
            4 hours ago













          • been there done that. just a quick edit is needed

            – soulshined
            4 hours ago



















          1














          a {
          text-decoration: none;
          }

          #span1{
          text-decoration:underline;
          }

          #myspan {
          color: black;
          text-decoration: none!important;

          }

          a:active #myspan {
          color: grey;
          text-decoration: none;
          }

          a:visited #myspan {
          color: yellow;
          text-decoration: none;
          }

          a:hover #myspan {
          color: red;
          text-decoration: none;
          }


          Make the above changes to the css.



          <a href="#"><span id="span1">A link </span><span id="myspan">some additional information</span></a>


          Make the changes to HTML.



          Let me know if it works






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54816830%2fhow-do-i-not-underline-an-element-in-a-link%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            6














            Make the element to be inline-block and it won't get affected by the underline:






            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            display:inline-block;
            }

            a:active #myspan {
            color: grey;
            }

            a:visited #myspan {
            color: yellow;
            }

            a:hover #myspan {
            color: red;
            }

            <a href="#">A link <span id="myspan">some additional information</span></a>






            Note that text decorations are not propagated to floating and absolutely positioned descendants, nor to the contents of atomic inline-level descendants such as inline blocks and inline tables. ref






            To remove the small space between text and span you can get rid of the whitespace and use a small margin:






            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            display:inline-block;
            margin-left:4px;
            }


            a:active #myspan {
            color: grey;
            }

            a:visited #myspan {
            color: yellow;
            }

            a:hover #myspan {
            color: red;
            }

            <a href="#">A link<span id="myspan">some additional information</span></a>








            share|improve this answer





















            • 1





              just learned something new. +1 Never had a reason to know this before today though.

              – soulshined
              4 hours ago
















            6














            Make the element to be inline-block and it won't get affected by the underline:






            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            display:inline-block;
            }

            a:active #myspan {
            color: grey;
            }

            a:visited #myspan {
            color: yellow;
            }

            a:hover #myspan {
            color: red;
            }

            <a href="#">A link <span id="myspan">some additional information</span></a>






            Note that text decorations are not propagated to floating and absolutely positioned descendants, nor to the contents of atomic inline-level descendants such as inline blocks and inline tables. ref






            To remove the small space between text and span you can get rid of the whitespace and use a small margin:






            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            display:inline-block;
            margin-left:4px;
            }


            a:active #myspan {
            color: grey;
            }

            a:visited #myspan {
            color: yellow;
            }

            a:hover #myspan {
            color: red;
            }

            <a href="#">A link<span id="myspan">some additional information</span></a>








            share|improve this answer





















            • 1





              just learned something new. +1 Never had a reason to know this before today though.

              – soulshined
              4 hours ago














            6












            6








            6







            Make the element to be inline-block and it won't get affected by the underline:






            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            display:inline-block;
            }

            a:active #myspan {
            color: grey;
            }

            a:visited #myspan {
            color: yellow;
            }

            a:hover #myspan {
            color: red;
            }

            <a href="#">A link <span id="myspan">some additional information</span></a>






            Note that text decorations are not propagated to floating and absolutely positioned descendants, nor to the contents of atomic inline-level descendants such as inline blocks and inline tables. ref






            To remove the small space between text and span you can get rid of the whitespace and use a small margin:






            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            display:inline-block;
            margin-left:4px;
            }


            a:active #myspan {
            color: grey;
            }

            a:visited #myspan {
            color: yellow;
            }

            a:hover #myspan {
            color: red;
            }

            <a href="#">A link<span id="myspan">some additional information</span></a>








            share|improve this answer















            Make the element to be inline-block and it won't get affected by the underline:






            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            display:inline-block;
            }

            a:active #myspan {
            color: grey;
            }

            a:visited #myspan {
            color: yellow;
            }

            a:hover #myspan {
            color: red;
            }

            <a href="#">A link <span id="myspan">some additional information</span></a>






            Note that text decorations are not propagated to floating and absolutely positioned descendants, nor to the contents of atomic inline-level descendants such as inline blocks and inline tables. ref






            To remove the small space between text and span you can get rid of the whitespace and use a small margin:






            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            display:inline-block;
            margin-left:4px;
            }


            a:active #myspan {
            color: grey;
            }

            a:visited #myspan {
            color: yellow;
            }

            a:hover #myspan {
            color: red;
            }

            <a href="#">A link<span id="myspan">some additional information</span></a>








            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            display:inline-block;
            }

            a:active #myspan {
            color: grey;
            }

            a:visited #myspan {
            color: yellow;
            }

            a:hover #myspan {
            color: red;
            }

            <a href="#">A link <span id="myspan">some additional information</span></a>





            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            display:inline-block;
            }

            a:active #myspan {
            color: grey;
            }

            a:visited #myspan {
            color: yellow;
            }

            a:hover #myspan {
            color: red;
            }

            <a href="#">A link <span id="myspan">some additional information</span></a>





            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            display:inline-block;
            margin-left:4px;
            }


            a:active #myspan {
            color: grey;
            }

            a:visited #myspan {
            color: yellow;
            }

            a:hover #myspan {
            color: red;
            }

            <a href="#">A link<span id="myspan">some additional information</span></a>





            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            display:inline-block;
            margin-left:4px;
            }


            a:active #myspan {
            color: grey;
            }

            a:visited #myspan {
            color: yellow;
            }

            a:hover #myspan {
            color: red;
            }

            <a href="#">A link<span id="myspan">some additional information</span></a>






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 4 hours ago

























            answered 4 hours ago









            Temani AfifTemani Afif

            74.5k94386




            74.5k94386








            • 1





              just learned something new. +1 Never had a reason to know this before today though.

              – soulshined
              4 hours ago














            • 1





              just learned something new. +1 Never had a reason to know this before today though.

              – soulshined
              4 hours ago








            1




            1





            just learned something new. +1 Never had a reason to know this before today though.

            – soulshined
            4 hours ago





            just learned something new. +1 Never had a reason to know this before today though.

            – soulshined
            4 hours ago













            3














            I made a:hover #myspan, a:hover






            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            text-decoration: none;
            }

            a:active #myspan {
            color: grey;
            text-decoration: none;
            }

            a:visited #myspan {
            color: yellow;
            text-decoration: none;
            }

            a:hover #myspan, a:hover {
            color: red;
            text-decoration: none;
            }

            <a href="#">A link <span id="myspan">some additional information</span></a>








            share|improve this answer
























            • dont think OP wants the span underlined under any conditions. underline the link except for the #myspan element

              – soulshined
              4 hours ago













            • oops. The answer is given below. I misunderstood.

              – Dogukan Cavus
              4 hours ago













            • been there done that. just a quick edit is needed

              – soulshined
              4 hours ago
















            3














            I made a:hover #myspan, a:hover






            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            text-decoration: none;
            }

            a:active #myspan {
            color: grey;
            text-decoration: none;
            }

            a:visited #myspan {
            color: yellow;
            text-decoration: none;
            }

            a:hover #myspan, a:hover {
            color: red;
            text-decoration: none;
            }

            <a href="#">A link <span id="myspan">some additional information</span></a>








            share|improve this answer
























            • dont think OP wants the span underlined under any conditions. underline the link except for the #myspan element

              – soulshined
              4 hours ago













            • oops. The answer is given below. I misunderstood.

              – Dogukan Cavus
              4 hours ago













            • been there done that. just a quick edit is needed

              – soulshined
              4 hours ago














            3












            3








            3







            I made a:hover #myspan, a:hover






            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            text-decoration: none;
            }

            a:active #myspan {
            color: grey;
            text-decoration: none;
            }

            a:visited #myspan {
            color: yellow;
            text-decoration: none;
            }

            a:hover #myspan, a:hover {
            color: red;
            text-decoration: none;
            }

            <a href="#">A link <span id="myspan">some additional information</span></a>








            share|improve this answer













            I made a:hover #myspan, a:hover






            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            text-decoration: none;
            }

            a:active #myspan {
            color: grey;
            text-decoration: none;
            }

            a:visited #myspan {
            color: yellow;
            text-decoration: none;
            }

            a:hover #myspan, a:hover {
            color: red;
            text-decoration: none;
            }

            <a href="#">A link <span id="myspan">some additional information</span></a>








            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            text-decoration: none;
            }

            a:active #myspan {
            color: grey;
            text-decoration: none;
            }

            a:visited #myspan {
            color: yellow;
            text-decoration: none;
            }

            a:hover #myspan, a:hover {
            color: red;
            text-decoration: none;
            }

            <a href="#">A link <span id="myspan">some additional information</span></a>





            a {
            text-decoration: underline;
            }

            a #myspan {
            color: black;
            text-decoration: none;
            }

            a:active #myspan {
            color: grey;
            text-decoration: none;
            }

            a:visited #myspan {
            color: yellow;
            text-decoration: none;
            }

            a:hover #myspan, a:hover {
            color: red;
            text-decoration: none;
            }

            <a href="#">A link <span id="myspan">some additional information</span></a>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 4 hours ago









            Dogukan CavusDogukan Cavus

            3,5312627




            3,5312627













            • dont think OP wants the span underlined under any conditions. underline the link except for the #myspan element

              – soulshined
              4 hours ago













            • oops. The answer is given below. I misunderstood.

              – Dogukan Cavus
              4 hours ago













            • been there done that. just a quick edit is needed

              – soulshined
              4 hours ago



















            • dont think OP wants the span underlined under any conditions. underline the link except for the #myspan element

              – soulshined
              4 hours ago













            • oops. The answer is given below. I misunderstood.

              – Dogukan Cavus
              4 hours ago













            • been there done that. just a quick edit is needed

              – soulshined
              4 hours ago

















            dont think OP wants the span underlined under any conditions. underline the link except for the #myspan element

            – soulshined
            4 hours ago







            dont think OP wants the span underlined under any conditions. underline the link except for the #myspan element

            – soulshined
            4 hours ago















            oops. The answer is given below. I misunderstood.

            – Dogukan Cavus
            4 hours ago







            oops. The answer is given below. I misunderstood.

            – Dogukan Cavus
            4 hours ago















            been there done that. just a quick edit is needed

            – soulshined
            4 hours ago





            been there done that. just a quick edit is needed

            – soulshined
            4 hours ago











            1














            a {
            text-decoration: none;
            }

            #span1{
            text-decoration:underline;
            }

            #myspan {
            color: black;
            text-decoration: none!important;

            }

            a:active #myspan {
            color: grey;
            text-decoration: none;
            }

            a:visited #myspan {
            color: yellow;
            text-decoration: none;
            }

            a:hover #myspan {
            color: red;
            text-decoration: none;
            }


            Make the above changes to the css.



            <a href="#"><span id="span1">A link </span><span id="myspan">some additional information</span></a>


            Make the changes to HTML.



            Let me know if it works






            share|improve this answer






























              1














              a {
              text-decoration: none;
              }

              #span1{
              text-decoration:underline;
              }

              #myspan {
              color: black;
              text-decoration: none!important;

              }

              a:active #myspan {
              color: grey;
              text-decoration: none;
              }

              a:visited #myspan {
              color: yellow;
              text-decoration: none;
              }

              a:hover #myspan {
              color: red;
              text-decoration: none;
              }


              Make the above changes to the css.



              <a href="#"><span id="span1">A link </span><span id="myspan">some additional information</span></a>


              Make the changes to HTML.



              Let me know if it works






              share|improve this answer




























                1












                1








                1







                a {
                text-decoration: none;
                }

                #span1{
                text-decoration:underline;
                }

                #myspan {
                color: black;
                text-decoration: none!important;

                }

                a:active #myspan {
                color: grey;
                text-decoration: none;
                }

                a:visited #myspan {
                color: yellow;
                text-decoration: none;
                }

                a:hover #myspan {
                color: red;
                text-decoration: none;
                }


                Make the above changes to the css.



                <a href="#"><span id="span1">A link </span><span id="myspan">some additional information</span></a>


                Make the changes to HTML.



                Let me know if it works






                share|improve this answer















                a {
                text-decoration: none;
                }

                #span1{
                text-decoration:underline;
                }

                #myspan {
                color: black;
                text-decoration: none!important;

                }

                a:active #myspan {
                color: grey;
                text-decoration: none;
                }

                a:visited #myspan {
                color: yellow;
                text-decoration: none;
                }

                a:hover #myspan {
                color: red;
                text-decoration: none;
                }


                Make the above changes to the css.



                <a href="#"><span id="span1">A link </span><span id="myspan">some additional information</span></a>


                Make the changes to HTML.



                Let me know if it works







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 3 hours ago

























                answered 4 hours ago









                SrijanSrijan

                314




                314






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54816830%2fhow-do-i-not-underline-an-element-in-a-link%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Щит и меч (фильм) Содержание Названия серий | Сюжет |...

                    Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

                    Meter-Bus Содержание Параметры шины | Стандартизация |...