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 4 hours ago
soulshined
5,04642248
5,04642248
asked 4 hours ago
Marissa LevyMarissa Levy
2721652103
2721652103
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
4 hours ago
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 thespan
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
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
4 hours ago
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
4 hours ago
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 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
add a comment |
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
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 thespan
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
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 thespan
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
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 4 hours ago
Dogukan CavusDogukan Cavus
3,5312627
3,5312627
dont think OP wants thespan
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
add a comment |
dont think OP wants thespan
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
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 4 hours ago
answered 4 hours ago
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