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;








0















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










share|improve this question






















  • 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

















0















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










share|improve this question






















  • 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













0












0








0


0






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










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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












3 Answers
3






active

oldest

votes


















1














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>








share|improve this answer

























  • This one worked for me ! Thanks

    – Ashwini
    Mar 24 at 6:07


















1














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>








share|improve this answer






























    -2














    h4.text-center:nth-child(2)

    color: red;






    share|improve this answer




















    • 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 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












    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
    );



    );













    draft saved

    draft discarded


















    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









    1














    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>








    share|improve this answer

























    • This one worked for me ! Thanks

      – Ashwini
      Mar 24 at 6:07















    1














    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>








    share|improve this answer

























    • This one worked for me ! Thanks

      – Ashwini
      Mar 24 at 6:07













    1












    1








    1







    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>








    share|improve this answer















    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>






    share|improve this answer














    share|improve this answer



    share|improve this answer








    answered Mar 23 at 11:10


























    community wiki





    Quentin













    • 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





    This one worked for me ! Thanks

    – Ashwini
    Mar 24 at 6:07













    1














    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>








    share|improve this answer



























      1














      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>








      share|improve this answer

























        1












        1








        1







        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>








        share|improve this answer













        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>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 23 at 11:08









        Hien NguyenHien Nguyen

        6,3603827




        6,3603827





















            -2














            h4.text-center:nth-child(2)

            color: red;






            share|improve this answer




















            • 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 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
















            -2














            h4.text-center:nth-child(2)

            color: red;






            share|improve this answer




















            • 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 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














            -2












            -2








            -2







            h4.text-center:nth-child(2)

            color: red;






            share|improve this answer















            h4.text-center:nth-child(2)

            color: red;







            share|improve this answer














            share|improve this answer



            share|improve this answer








            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 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













            • 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 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








            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


















            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript