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>
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>
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";
Select and style all elements with class="news":
syntax:
.class {
css declarations;
}
for example
.news{
background-color: yellow;
}