英文:
How to implement inline styling for href
问题
I am trying to perform inline styling for anchor tags. I know you can do a style in the head but that is not what I am trying to do. I looked online and saw that you can do a simple <a href="#link" style="color: #ff600">Link 1 </a>
. However I cannot seem to find an answer to do inline styling for when it is visited.
I am trying to convert these below to inline style.
<style>
a:link {
color: red;
}
a:visited {
color: blue;
text-decoration: purple;
}
</style>
I have tried the following, but it does not work.
<a style="a:link color: red; a:visited color: blue text-decoration: purple;" href="https://www.google.com">search here</a>
Here is a sample code if it helps to visualize it.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Hello World!</h1>
<a style="a:link color: red; a:visited color: blue text-decoration: purple;" href="https://www.google.com">search here</a>
</body>
</html>
How can I do this translation into inline styling?
英文:
I am trying to perform inline styling for anchor tags. I know you can do a style in the head but that is not what I am trying to do. I looked online and saw that you can do a simple <a href="#link" style="color: #ff600">Link 1 </a>
. However I cannot seem to find an answer to do inline styling for when it is visited.
I am trying to convert these below to inline style.
<style>
a:link {
color: red;
}
a:visited {
color: blue;
text-decoration: purple;
}
</style>
I have tried the following, but it does not work.
<a style="a:link color: red; a:visited color: blue text-decoration: purple;" href="https://www.google.com">search here</a>
Here is a sample code if it helps to visualize it.
<!DOCTYPE html>
<html>
<head>
<!-- <style>
a:link {
color: red;
}
a:visited {
color: blue;
text-decoration: purple;
}
</style> -->
</head>
<body>
<h1>Hello World!</h1>
<a style="a:link color: red; a:visited color: blue text-decoration: purple;" href="https://www.google.com">search here</a>
</body>
</html>
How can I do this translation into inline styling?
答案1
得分: 3
很抱歉,:link 和 :visited 伪类不能直接应用于内联样式。类似 :link 和 :visited 的伪类属于CSS选择器的一部分,无法在内联样式中表示。
英文:
Unfortunately, the :link and :visited pseudo-classes cannot be directly applied using inline styles. Pseudo-classes like :link and :visited are part of CSS selectors and cannot be represented in inline styles.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论