0

I need to apply some css styles to a tag with a specific class, for example I need to select article tag with news class.

<article class="news" >
  <div>some stuff</div>
</article>
Youssouf Oumar
  • 29,373
  • 11
  • 46
  • 65
Iulix Dim
  • 37
  • 6

2 Answers2

4

You can do it this way with CSS:

article.news{
  /* add styles below */
}

You can do it this way with JavaScript:

let articleNews = document.querySelector("article.news");
// for example
articleNews.style.color = "red";
Youssouf Oumar
  • 29,373
  • 11
  • 46
  • 65
0

Select and style all elements with class="news":

syntax:

.class {
  css declarations;
} 

for example

.news{
  background-color: yellow;
}
madaraUchiha
  • 41
  • 1
  • 8