How do I not underline an element in a link?
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>
html css
add a comment |
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>
html css
add a comment |
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>
html css
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
html css
edited yesterday
soulshined
5,15142248
5,15142248
asked yesterday
Marissa LevyMarissa Levy
2771652103
2771652103
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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>
1
just learned something new. +1 Never had a reason to know this before today though.
– soulshined
yesterday
add a comment |
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>
dont think OP wants thespanunderlined under any conditions. underline the link except for the #myspan element
– soulshined
yesterday
oops. The answer is given below. I misunderstood.
– Dogukan Cavus
yesterday
been there done that. just a quick edit is needed
– soulshined
yesterday
add a comment |
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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>
1
just learned something new. +1 Never had a reason to know this before today though.
– soulshined
yesterday
add a comment |
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>
1
just learned something new. +1 Never had a reason to know this before today though.
– soulshined
yesterday
add a comment |
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>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>edited yesterday
answered yesterday
Temani AfifTemani Afif
74.8k94386
74.8k94386
1
just learned something new. +1 Never had a reason to know this before today though.
– soulshined
yesterday
add a comment |
1
just learned something new. +1 Never had a reason to know this before today though.
– soulshined
yesterday
1
1
just learned something new. +1 Never had a reason to know this before today though.
– soulshined
yesterday
just learned something new. +1 Never had a reason to know this before today though.
– soulshined
yesterday
add a comment |
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>
dont think OP wants thespanunderlined under any conditions. underline the link except for the #myspan element
– soulshined
yesterday
oops. The answer is given below. I misunderstood.
– Dogukan Cavus
yesterday
been there done that. just a quick edit is needed
– soulshined
yesterday
add a comment |
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>
dont think OP wants thespanunderlined under any conditions. underline the link except for the #myspan element
– soulshined
yesterday
oops. The answer is given below. I misunderstood.
– Dogukan Cavus
yesterday
been there done that. just a quick edit is needed
– soulshined
yesterday
add a comment |
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>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>answered yesterday
Dogukan CavusDogukan Cavus
3,7992627
3,7992627
dont think OP wants thespanunderlined under any conditions. underline the link except for the #myspan element
– soulshined
yesterday
oops. The answer is given below. I misunderstood.
– Dogukan Cavus
yesterday
been there done that. just a quick edit is needed
– soulshined
yesterday
add a comment |
dont think OP wants thespanunderlined under any conditions. underline the link except for the #myspan element
– soulshined
yesterday
oops. The answer is given below. I misunderstood.
– Dogukan Cavus
yesterday
been there done that. just a quick edit is needed
– soulshined
yesterday
dont think OP wants the
span underlined under any conditions. underline the link except for the #myspan element– soulshined
yesterday
dont think OP wants the
span underlined under any conditions. underline the link except for the #myspan element– soulshined
yesterday
oops. The answer is given below. I misunderstood.
– Dogukan Cavus
yesterday
oops. The answer is given below. I misunderstood.
– Dogukan Cavus
yesterday
been there done that. just a quick edit is needed
– soulshined
yesterday
been there done that. just a quick edit is needed
– soulshined
yesterday
add a comment |
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
add a comment |
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
add a comment |
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
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
edited yesterday
answered yesterday
SrijanSrijan
314
314
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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