0

I tried attaching a link to my heading but i ended up having the style of the text formatted. What did i do wrong

h2 {
  color: green;
  text-align: right;
  border: 2px solid purple;
  text-decoration: none;
}
<h2><a href="#">Sign in</a></h2>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415

2 Answers2

0

Here is one of the possible solutions :

h2{
    color:green;
    text-align: right;
    border: 2px solid purple;
    text-decoration: none;

}
a{
 color:green;
 text-decoration: none;
}
   <h2> <a href="#">Sign IN</a></h2>
Atimene Nazim
  • 409
  • 3
  • 13
0

I think you can use inherit here to save setting the same color etc twice.

Links have default colors depending on their states which have to be overridden.

h2 {
  color: green;
  text-align: right;
  border: 2px solid purple;
  text-decoration: none;
}

h2 a {
  color: inherit;
  text-decoration: inherit;
}
<h2><a href="#">Sign in</a></h2>

or even...currentColor..

h2 {
  color: green;
  text-align: right;
  border: 2px solid purple;
  text-decoration: none;
}

h2 a {
  color: currentColor;
  text-decoration: inherit;
}
<h2><a href="#">Sign in</a></h2>
Paulie_D
  • 107,962
  • 13
  • 142
  • 161