Apply different css style to two same h4 tag which has same class nameWhich characters are valid in CSS class names/selectors?CSS Selector that applies to elements with two classesApplying class styles with jquery, but not all styles are applyingHow to exclude particular class name in CSS selector?css style for div tagCannot display HTML stringHow to change the css class name dynamically in angular 2Applying CSS classes to plugin-generated elements of the same tag?applying hover to all elements with same class name with cssApply CSS-Style to HTML classes created with javascript
Why is it so slow when assigning a concatenated string to a variable in python?
Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019
Cropping a message using array splits
International Code of Ethics for order of co-authors in research papers
What is the significance of 4200 BCE in context of farming replacing foraging in Europe?
How Car Rear View Mirrors Work
What is the airplane type in this formation seen above Eugene, Oregon?
How to align underlines in a cases environment
How to select certain lines (n, n+4, n+8, n+12...) from the file?
On what legal basis did the UK remove the 'European Union' from its passport?
Exception propagation: When to catch exceptions?
Was there a contingency plan in place if Little Boy failed to detonate?
Understanding basic photoresistor circuit
Delta TSA-Precheck status removed
Why in a Ethernet LAN, a packet sniffer can obtain all packets sent over the LAN?
Was this a power play by Daenerys?
Why does a C.D.F need to be right-continuous?
How can a Lich look like a human without magic?
Washer drain pipe overflow
Guns in space with bullets that return?
How do I compare the result of "1d20+x, with advantage" to "1d20+y, without advantage", assuming x < y?
What did Rocket give Hawkeye in "Avengers: Endgame"?
Is the schwa sound consistent?
Does the 500 feet falling cap apply per fall, or per turn?
Apply different css style to two same h4 tag which has same class name
Which characters are valid in CSS class names/selectors?CSS Selector that applies to elements with two classesApplying class styles with jquery, but not all styles are applyingHow to exclude particular class name in CSS selector?css style for div tagCannot display HTML stringHow to change the css class name dynamically in angular 2Applying CSS classes to plugin-generated elements of the same tag?applying hover to all elements with same class name with cssApply CSS-Style to HTML classes created with javascript
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am having two h4 tags with same classs name. I want to change the color of second h4 tag value. But the color applying to the 1st tag also. I don't know how to differentiate the 1st tag from the second one
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart2</h4>
I want to change the color of the text only using css. I cant' add or change anything in html side
html css
add a comment |
I am having two h4 tags with same classs name. I want to change the color of second h4 tag value. But the color applying to the 1st tag also. I don't know how to differentiate the 1st tag from the second one
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart2</h4>
I want to change the color of the text only using css. I cant' add or change anything in html side
html css
You can use a sibbling selector :.text-center.vertical-spacing-5 color:yellow .text-center.vertical-spacing-5 ~ .text-center.vertical-spacing-5 color:red
– G-Cyr
Mar 23 at 11:07
1
@G-Cyr — Only if they are sibblings
– Quentin
Mar 23 at 11:08
As commented, are they siblings?
– LGSon
Mar 23 at 11:12
I can't use sibling selectors. They are not siblings. both are in different div
– Ashwini
Mar 24 at 5:38
1
but the parent are sibblings :)
– G-Cyr
Mar 24 at 8:50
add a comment |
I am having two h4 tags with same classs name. I want to change the color of second h4 tag value. But the color applying to the 1st tag also. I don't know how to differentiate the 1st tag from the second one
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart2</h4>
I want to change the color of the text only using css. I cant' add or change anything in html side
html css
I am having two h4 tags with same classs name. I want to change the color of second h4 tag value. But the color applying to the 1st tag also. I don't know how to differentiate the 1st tag from the second one
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart2</h4>
I want to change the color of the text only using css. I cant' add or change anything in html side
html css
html css
asked Mar 23 at 11:05
AshwiniAshwini
71215
71215
You can use a sibbling selector :.text-center.vertical-spacing-5 color:yellow .text-center.vertical-spacing-5 ~ .text-center.vertical-spacing-5 color:red
– G-Cyr
Mar 23 at 11:07
1
@G-Cyr — Only if they are sibblings
– Quentin
Mar 23 at 11:08
As commented, are they siblings?
– LGSon
Mar 23 at 11:12
I can't use sibling selectors. They are not siblings. both are in different div
– Ashwini
Mar 24 at 5:38
1
but the parent are sibblings :)
– G-Cyr
Mar 24 at 8:50
add a comment |
You can use a sibbling selector :.text-center.vertical-spacing-5 color:yellow .text-center.vertical-spacing-5 ~ .text-center.vertical-spacing-5 color:red
– G-Cyr
Mar 23 at 11:07
1
@G-Cyr — Only if they are sibblings
– Quentin
Mar 23 at 11:08
As commented, are they siblings?
– LGSon
Mar 23 at 11:12
I can't use sibling selectors. They are not siblings. both are in different div
– Ashwini
Mar 24 at 5:38
1
but the parent are sibblings :)
– G-Cyr
Mar 24 at 8:50
You can use a sibbling selector :
.text-center.vertical-spacing-5 color:yellow .text-center.vertical-spacing-5 ~ .text-center.vertical-spacing-5 color:red
– G-Cyr
Mar 23 at 11:07
You can use a sibbling selector :
.text-center.vertical-spacing-5 color:yellow .text-center.vertical-spacing-5 ~ .text-center.vertical-spacing-5 color:red
– G-Cyr
Mar 23 at 11:07
1
1
@G-Cyr — Only if they are sibblings
– Quentin
Mar 23 at 11:08
@G-Cyr — Only if they are sibblings
– Quentin
Mar 23 at 11:08
As commented, are they siblings?
– LGSon
Mar 23 at 11:12
As commented, are they siblings?
– LGSon
Mar 23 at 11:12
I can't use sibling selectors. They are not siblings. both are in different div
– Ashwini
Mar 24 at 5:38
I can't use sibling selectors. They are not siblings. both are in different div
– Ashwini
Mar 24 at 5:38
1
1
but the parent are sibblings :)
– G-Cyr
Mar 24 at 8:50
but the parent are sibblings :)
– G-Cyr
Mar 24 at 8:50
add a comment |
3 Answers
3
active
oldest
votes
Since the elements are identical, you can only distinguish between them describing their relationships with other elements using combinators and/or structural pseudo-classes.
Since these depend on the position of the other elements DOM structure, the specifics of how you do this depends on what that DOM structure is.
For example, if the structure was something like this:
h4
color: red;
section+section h4
color: blue;
<div id="example">
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
</div>
This one worked for me ! Thanks
– Ashwini
Mar 24 at 6:07
add a comment |
You can use h4.vertical-spacing-5:nth-of-type(2)
h4.vertical-spacing-5:nth-of-type(2)
color: red;
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart2</h4>
add a comment |
h4.text-center:nth-child(2)
color: red;
4
Please don't write code-only answers, try to explain what you're doing.
– JJJ
Mar 23 at 11:24
1
The question is tagged withhtml
andcss
, notjquery
, so if you want to provide with an non-tagged tech, ask first if that is an option
– LGSon
Mar 23 at 11:27
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313040%2fapply-different-css-style-to-two-same-h4-tag-which-has-same-class-name%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Since the elements are identical, you can only distinguish between them describing their relationships with other elements using combinators and/or structural pseudo-classes.
Since these depend on the position of the other elements DOM structure, the specifics of how you do this depends on what that DOM structure is.
For example, if the structure was something like this:
h4
color: red;
section+section h4
color: blue;
<div id="example">
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
</div>
This one worked for me ! Thanks
– Ashwini
Mar 24 at 6:07
add a comment |
Since the elements are identical, you can only distinguish between them describing their relationships with other elements using combinators and/or structural pseudo-classes.
Since these depend on the position of the other elements DOM structure, the specifics of how you do this depends on what that DOM structure is.
For example, if the structure was something like this:
h4
color: red;
section+section h4
color: blue;
<div id="example">
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
</div>
This one worked for me ! Thanks
– Ashwini
Mar 24 at 6:07
add a comment |
Since the elements are identical, you can only distinguish between them describing their relationships with other elements using combinators and/or structural pseudo-classes.
Since these depend on the position of the other elements DOM structure, the specifics of how you do this depends on what that DOM structure is.
For example, if the structure was something like this:
h4
color: red;
section+section h4
color: blue;
<div id="example">
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
</div>
Since the elements are identical, you can only distinguish between them describing their relationships with other elements using combinators and/or structural pseudo-classes.
Since these depend on the position of the other elements DOM structure, the specifics of how you do this depends on what that DOM structure is.
For example, if the structure was something like this:
h4
color: red;
section+section h4
color: blue;
<div id="example">
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
</div>
h4
color: red;
section+section h4
color: blue;
<div id="example">
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
</div>
h4
color: red;
section+section h4
color: blue;
<div id="example">
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
<section>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<p>Ipsum…</p>
</section>
</div>
answered Mar 23 at 11:10
community wiki
Quentin
This one worked for me ! Thanks
– Ashwini
Mar 24 at 6:07
add a comment |
This one worked for me ! Thanks
– Ashwini
Mar 24 at 6:07
This one worked for me ! Thanks
– Ashwini
Mar 24 at 6:07
This one worked for me ! Thanks
– Ashwini
Mar 24 at 6:07
add a comment |
You can use h4.vertical-spacing-5:nth-of-type(2)
h4.vertical-spacing-5:nth-of-type(2)
color: red;
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart2</h4>
add a comment |
You can use h4.vertical-spacing-5:nth-of-type(2)
h4.vertical-spacing-5:nth-of-type(2)
color: red;
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart2</h4>
add a comment |
You can use h4.vertical-spacing-5:nth-of-type(2)
h4.vertical-spacing-5:nth-of-type(2)
color: red;
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart2</h4>
You can use h4.vertical-spacing-5:nth-of-type(2)
h4.vertical-spacing-5:nth-of-type(2)
color: red;
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart2</h4>
h4.vertical-spacing-5:nth-of-type(2)
color: red;
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart2</h4>
h4.vertical-spacing-5:nth-of-type(2)
color: red;
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart1</h4>
<h4 _ngcontent-c2="" class="text-center vertical-spacing-5">Job Cart2</h4>
answered Mar 23 at 11:08
Hien NguyenHien Nguyen
6,3603827
6,3603827
add a comment |
add a comment |
h4.text-center:nth-child(2)
color: red;
4
Please don't write code-only answers, try to explain what you're doing.
– JJJ
Mar 23 at 11:24
1
The question is tagged withhtml
andcss
, notjquery
, so if you want to provide with an non-tagged tech, ask first if that is an option
– LGSon
Mar 23 at 11:27
add a comment |
h4.text-center:nth-child(2)
color: red;
4
Please don't write code-only answers, try to explain what you're doing.
– JJJ
Mar 23 at 11:24
1
The question is tagged withhtml
andcss
, notjquery
, so if you want to provide with an non-tagged tech, ask first if that is an option
– LGSon
Mar 23 at 11:27
add a comment |
h4.text-center:nth-child(2)
color: red;
h4.text-center:nth-child(2)
color: red;
edited Mar 23 at 11:34
answered Mar 23 at 11:20
gvngvn
12
12
4
Please don't write code-only answers, try to explain what you're doing.
– JJJ
Mar 23 at 11:24
1
The question is tagged withhtml
andcss
, notjquery
, so if you want to provide with an non-tagged tech, ask first if that is an option
– LGSon
Mar 23 at 11:27
add a comment |
4
Please don't write code-only answers, try to explain what you're doing.
– JJJ
Mar 23 at 11:24
1
The question is tagged withhtml
andcss
, notjquery
, so if you want to provide with an non-tagged tech, ask first if that is an option
– LGSon
Mar 23 at 11:27
4
4
Please don't write code-only answers, try to explain what you're doing.
– JJJ
Mar 23 at 11:24
Please don't write code-only answers, try to explain what you're doing.
– JJJ
Mar 23 at 11:24
1
1
The question is tagged with
html
and css
, not jquery
, so if you want to provide with an non-tagged tech, ask first if that is an option– LGSon
Mar 23 at 11:27
The question is tagged with
html
and css
, not jquery
, so if you want to provide with an non-tagged tech, ask first if that is an option– LGSon
Mar 23 at 11:27
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313040%2fapply-different-css-style-to-two-same-h4-tag-which-has-same-class-name%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You can use a sibbling selector :
.text-center.vertical-spacing-5 color:yellow .text-center.vertical-spacing-5 ~ .text-center.vertical-spacing-5 color:red
– G-Cyr
Mar 23 at 11:07
1
@G-Cyr — Only if they are sibblings
– Quentin
Mar 23 at 11:08
As commented, are they siblings?
– LGSon
Mar 23 at 11:12
I can't use sibling selectors. They are not siblings. both are in different div
– Ashwini
Mar 24 at 5:38
1
but the parent are sibblings :)
– G-Cyr
Mar 24 at 8:50