In my code, there are a couple of h5 headings and I want to style only one of them without changing the others. I tried using the following code in my CSS file:
h5{
color:blue;
text-align:center;
}
Apparently, this changes every h5 heading I have in my HTML code which is not what I wanted. How do I fix this?
CodePudding user response:
You could try to have different id's for each header. Like the example below
<h5 id="header1"></h5>
<h5 id="header2"></h5>
<h5 id="header3"></h5>
<h5 id="header4"></h5>
Then in css you can control each element with the id.
#header1{
color:red;
}
#header2{
color:blue;
}
#header3{
color:white;
}
#header4{
color:black;
}
Please note that ids cannot start with a number
CodePudding user response:
You can set id
or class
attribute to each element.
look this article: https://www.w3schools.com/css/css_selectors.asp
CodePudding user response:
you should have this h5 inside another HTML element.
you can use nth:child()
css selector.
try this: