inquisitivemongoose
inquisitivemongoose

Reputation: 396

How to target all CSS link selectors?

Is there a better way to target these selectors instead of having to repeat them like below?

h1 a:hover {
  color: black;
  text-decoration: none;
}

h1 a:active {
  color: black;
  text-decoration: none;
}

h1 a:link {
  color: black;
  text-decoration: none;
}

h1 a:visited {
  color: black;
  text-decoration: none;
}

Upvotes: 0

Views: 54

Answers (2)

HAPPY SINGH
HAPPY SINGH

Reputation: 586

Yes, We can use commas for a separate style CSS and reduce CSS lines.

h1 a:hover,
h1 a:active,
h1 a:link,
h1 a:visited {
  color: black;
  text-decoration: none;
}

Upvotes: 0

j08691
j08691

Reputation: 207983

Yes, simply separate them with commas:

h1 a:hover, h1 a:active, h1 a:link, h1 a:visited {
  color: black;
  text-decoration: none;
}

You might want to brush up on the basics of CSS

Upvotes: 2

Related Questions