How to select an img after the first p tag with css?









up vote
0
down vote

favorite












I have this html:



<div class="entry-content">
<p>
<img src="foto.jpg">
</p>
<p>lorem</p>
<p>foo</p>
</div>


and this css:



.entry-content
border: none !important;
padding: 0;

p
margin: 16px 16px 0 16px;

.entry-content img
margin: 0 0 0 0;




I tried to select the img to keep margins at 0 only and let the others p tags have the 16px but it doesn't work.



My goal is to keep all the p tags with 16px margin except the first one because there's an image inside of it i'd like to keep 100% width of the container.



Actually i do can add a class to the img tag if it helps



Thanks a lot for your help










share|improve this question























  • Within first p tag or after?
    – Ahmad Hassan
    Nov 9 at 1:16










  • You're not actually trying to select the <img> tag; it sounds like you want the rules to apply to the parent <p> tag itself. There's no parent selector in CSS, and :contains doesn't exist yet, so you may need JavaScript for this. Is the offending <p> tag always going to be the first child of .entry-content?
    – Obsidian Age
    Nov 9 at 1:16











  • Within the first p tag, that's right
    – Felipe Lima
    Nov 9 at 1:17










  • Yes, the theme i'm using for wordpress always put the img inside the first p tag
    – Felipe Lima
    Nov 9 at 1:19










  • Best idea would be to add a class for the image. Removes the need for complex selectors.
    – Sujan Sundareswaran
    Nov 9 at 1:24














up vote
0
down vote

favorite












I have this html:



<div class="entry-content">
<p>
<img src="foto.jpg">
</p>
<p>lorem</p>
<p>foo</p>
</div>


and this css:



.entry-content
border: none !important;
padding: 0;

p
margin: 16px 16px 0 16px;

.entry-content img
margin: 0 0 0 0;




I tried to select the img to keep margins at 0 only and let the others p tags have the 16px but it doesn't work.



My goal is to keep all the p tags with 16px margin except the first one because there's an image inside of it i'd like to keep 100% width of the container.



Actually i do can add a class to the img tag if it helps



Thanks a lot for your help










share|improve this question























  • Within first p tag or after?
    – Ahmad Hassan
    Nov 9 at 1:16










  • You're not actually trying to select the <img> tag; it sounds like you want the rules to apply to the parent <p> tag itself. There's no parent selector in CSS, and :contains doesn't exist yet, so you may need JavaScript for this. Is the offending <p> tag always going to be the first child of .entry-content?
    – Obsidian Age
    Nov 9 at 1:16











  • Within the first p tag, that's right
    – Felipe Lima
    Nov 9 at 1:17










  • Yes, the theme i'm using for wordpress always put the img inside the first p tag
    – Felipe Lima
    Nov 9 at 1:19










  • Best idea would be to add a class for the image. Removes the need for complex selectors.
    – Sujan Sundareswaran
    Nov 9 at 1:24












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have this html:



<div class="entry-content">
<p>
<img src="foto.jpg">
</p>
<p>lorem</p>
<p>foo</p>
</div>


and this css:



.entry-content
border: none !important;
padding: 0;

p
margin: 16px 16px 0 16px;

.entry-content img
margin: 0 0 0 0;




I tried to select the img to keep margins at 0 only and let the others p tags have the 16px but it doesn't work.



My goal is to keep all the p tags with 16px margin except the first one because there's an image inside of it i'd like to keep 100% width of the container.



Actually i do can add a class to the img tag if it helps



Thanks a lot for your help










share|improve this question















I have this html:



<div class="entry-content">
<p>
<img src="foto.jpg">
</p>
<p>lorem</p>
<p>foo</p>
</div>


and this css:



.entry-content
border: none !important;
padding: 0;

p
margin: 16px 16px 0 16px;

.entry-content img
margin: 0 0 0 0;




I tried to select the img to keep margins at 0 only and let the others p tags have the 16px but it doesn't work.



My goal is to keep all the p tags with 16px margin except the first one because there's an image inside of it i'd like to keep 100% width of the container.



Actually i do can add a class to the img tag if it helps



Thanks a lot for your help







html css






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 2:02

























asked Nov 9 at 1:11









Felipe Lima

11




11











  • Within first p tag or after?
    – Ahmad Hassan
    Nov 9 at 1:16










  • You're not actually trying to select the <img> tag; it sounds like you want the rules to apply to the parent <p> tag itself. There's no parent selector in CSS, and :contains doesn't exist yet, so you may need JavaScript for this. Is the offending <p> tag always going to be the first child of .entry-content?
    – Obsidian Age
    Nov 9 at 1:16











  • Within the first p tag, that's right
    – Felipe Lima
    Nov 9 at 1:17










  • Yes, the theme i'm using for wordpress always put the img inside the first p tag
    – Felipe Lima
    Nov 9 at 1:19










  • Best idea would be to add a class for the image. Removes the need for complex selectors.
    – Sujan Sundareswaran
    Nov 9 at 1:24
















  • Within first p tag or after?
    – Ahmad Hassan
    Nov 9 at 1:16










  • You're not actually trying to select the <img> tag; it sounds like you want the rules to apply to the parent <p> tag itself. There's no parent selector in CSS, and :contains doesn't exist yet, so you may need JavaScript for this. Is the offending <p> tag always going to be the first child of .entry-content?
    – Obsidian Age
    Nov 9 at 1:16











  • Within the first p tag, that's right
    – Felipe Lima
    Nov 9 at 1:17










  • Yes, the theme i'm using for wordpress always put the img inside the first p tag
    – Felipe Lima
    Nov 9 at 1:19










  • Best idea would be to add a class for the image. Removes the need for complex selectors.
    – Sujan Sundareswaran
    Nov 9 at 1:24















Within first p tag or after?
– Ahmad Hassan
Nov 9 at 1:16




Within first p tag or after?
– Ahmad Hassan
Nov 9 at 1:16












You're not actually trying to select the <img> tag; it sounds like you want the rules to apply to the parent <p> tag itself. There's no parent selector in CSS, and :contains doesn't exist yet, so you may need JavaScript for this. Is the offending <p> tag always going to be the first child of .entry-content?
– Obsidian Age
Nov 9 at 1:16





You're not actually trying to select the <img> tag; it sounds like you want the rules to apply to the parent <p> tag itself. There's no parent selector in CSS, and :contains doesn't exist yet, so you may need JavaScript for this. Is the offending <p> tag always going to be the first child of .entry-content?
– Obsidian Age
Nov 9 at 1:16













Within the first p tag, that's right
– Felipe Lima
Nov 9 at 1:17




Within the first p tag, that's right
– Felipe Lima
Nov 9 at 1:17












Yes, the theme i'm using for wordpress always put the img inside the first p tag
– Felipe Lima
Nov 9 at 1:19




Yes, the theme i'm using for wordpress always put the img inside the first p tag
– Felipe Lima
Nov 9 at 1:19












Best idea would be to add a class for the image. Removes the need for complex selectors.
– Sujan Sundareswaran
Nov 9 at 1:24




Best idea would be to add a class for the image. Removes the need for complex selectors.
– Sujan Sundareswaran
Nov 9 at 1:24












7 Answers
7






active

oldest

votes

















up vote
0
down vote













.entry-content p>img 
// your css






share|improve this answer




















  • if you can add a class to your image then add a class like <img class="no-margin-image"> and do .no-margin-image margin: 0;
    – Zuriel
    Nov 9 at 1:24










  • i did but it also didn't work :(
    – Felipe Lima
    Nov 9 at 1:55

















up vote
0
down vote













I am not sure you want after first p tag or within first p tag but as per your code, it should be like



.entry-content p:first-child img
//your css



If you have some other tag before p tag, you need to use



.entry-content p:first-of-type img
//your css






share|improve this answer






















  • I want within the first p tag.
    – Felipe Lima
    Nov 9 at 1:21










  • Try the above code..
    – Ahmad Hassan
    Nov 9 at 1:24










  • nope, none of the answers worked :(
    – Felipe Lima
    Nov 9 at 1:54

















up vote
0
down vote













You tried define your style inline, only for the first img?






share|improve this answer



























    up vote
    0
    down vote













    Try p img
    //your css
    .. if that doesn't work then create a fiddle or codepen so we can assist you better.






    share|improve this answer



























      up vote
      0
      down vote














      My goal is to keep all the p tags with 16px margin except the first one because there's an image inside of it i'd like to keep 100% width of the container.




      CSS currently cannot look down into the children of an element and then modify the parent or other elements around it. Everything cascades downward in a nested fashion.



      In other words it cannot say "There is an image inside this paragraph. I need to now change the style of the paragraph that is holding this image and give it a smaller margin."



      There are only really going to be two ways to accomplish this.



      One: You can create a class you manually assign to all the paragraphs that contain an image. So you'd have something like this:



      .entry-content img, .margin-override
      margin: 0 0 0 0;



      Then on your paragraph you'll do like this...



      <div class="entry-content">
      <p class="margin-override">
      <img src="foto.jpg">
      </p>
      <p>lorem</p>
      <p>foo</p>
      </div>


      Which will set there to be no margin on your image or the paragraph containing the image.



      Two: The other option is to use javascript/jQuery to search if a paragraph contains an image and then do an action to modify the margins of that paragraph when an image is found.



      You say you're doing this for a wordpress theme. Wordpress comes packaged with jQuery by default these days so unless you've overridden that it's already in place for you. The next step would be writing a script for yourself to target these paragraphs and script enqueue if with your theme.



      Here is a decent tutorial on how to add your own scripts to a wordpress theme.






      share|improve this answer



























        up vote
        0
        down vote
















        .entry-content
        border: none !important;
        padding: 0;

        p
        margin: 16px 16px 0 16px;

        .lafoto
        width: 200px;
        height: auto;
        margin: 0 0 0 0;

        <div class="entry-content">
        <p>
        <img class="lafoto" src="https://i.imgur.com/bfMLLDz.jpg">
        </p>
        <p>lorem</p>
        <p>foo</p>
        </div>
        and this css:





        Just add a class to the image, or an id, its that simple.






        share|improve this answer



























          up vote
          0
          down vote













          There are many possible ways of doing it. First of all I would like to know why you are displaying the image nested within




          Try this :- Instead of giving margin to P tag, assign margin to img tag, it will resolve your problem.






          share|improve this answer




















            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',
            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%2f53218426%2fhow-to-select-an-img-after-the-first-p-tag-with-css%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            7 Answers
            7






            active

            oldest

            votes








            7 Answers
            7






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            .entry-content p>img 
            // your css






            share|improve this answer




















            • if you can add a class to your image then add a class like <img class="no-margin-image"> and do .no-margin-image margin: 0;
              – Zuriel
              Nov 9 at 1:24










            • i did but it also didn't work :(
              – Felipe Lima
              Nov 9 at 1:55














            up vote
            0
            down vote













            .entry-content p>img 
            // your css






            share|improve this answer




















            • if you can add a class to your image then add a class like <img class="no-margin-image"> and do .no-margin-image margin: 0;
              – Zuriel
              Nov 9 at 1:24










            • i did but it also didn't work :(
              – Felipe Lima
              Nov 9 at 1:55












            up vote
            0
            down vote










            up vote
            0
            down vote









            .entry-content p>img 
            // your css






            share|improve this answer












            .entry-content p>img 
            // your css







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 9 at 1:21









            Zuriel

            1,3041224




            1,3041224











            • if you can add a class to your image then add a class like <img class="no-margin-image"> and do .no-margin-image margin: 0;
              – Zuriel
              Nov 9 at 1:24










            • i did but it also didn't work :(
              – Felipe Lima
              Nov 9 at 1:55
















            • if you can add a class to your image then add a class like <img class="no-margin-image"> and do .no-margin-image margin: 0;
              – Zuriel
              Nov 9 at 1:24










            • i did but it also didn't work :(
              – Felipe Lima
              Nov 9 at 1:55















            if you can add a class to your image then add a class like <img class="no-margin-image"> and do .no-margin-image margin: 0;
            – Zuriel
            Nov 9 at 1:24




            if you can add a class to your image then add a class like <img class="no-margin-image"> and do .no-margin-image margin: 0;
            – Zuriel
            Nov 9 at 1:24












            i did but it also didn't work :(
            – Felipe Lima
            Nov 9 at 1:55




            i did but it also didn't work :(
            – Felipe Lima
            Nov 9 at 1:55












            up vote
            0
            down vote













            I am not sure you want after first p tag or within first p tag but as per your code, it should be like



            .entry-content p:first-child img
            //your css



            If you have some other tag before p tag, you need to use



            .entry-content p:first-of-type img
            //your css






            share|improve this answer






















            • I want within the first p tag.
              – Felipe Lima
              Nov 9 at 1:21










            • Try the above code..
              – Ahmad Hassan
              Nov 9 at 1:24










            • nope, none of the answers worked :(
              – Felipe Lima
              Nov 9 at 1:54














            up vote
            0
            down vote













            I am not sure you want after first p tag or within first p tag but as per your code, it should be like



            .entry-content p:first-child img
            //your css



            If you have some other tag before p tag, you need to use



            .entry-content p:first-of-type img
            //your css






            share|improve this answer






















            • I want within the first p tag.
              – Felipe Lima
              Nov 9 at 1:21










            • Try the above code..
              – Ahmad Hassan
              Nov 9 at 1:24










            • nope, none of the answers worked :(
              – Felipe Lima
              Nov 9 at 1:54












            up vote
            0
            down vote










            up vote
            0
            down vote









            I am not sure you want after first p tag or within first p tag but as per your code, it should be like



            .entry-content p:first-child img
            //your css



            If you have some other tag before p tag, you need to use



            .entry-content p:first-of-type img
            //your css






            share|improve this answer














            I am not sure you want after first p tag or within first p tag but as per your code, it should be like



            .entry-content p:first-child img
            //your css



            If you have some other tag before p tag, you need to use



            .entry-content p:first-of-type img
            //your css







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 9 at 1:22

























            answered Nov 9 at 1:19









            Ahmad Hassan

            212112




            212112











            • I want within the first p tag.
              – Felipe Lima
              Nov 9 at 1:21










            • Try the above code..
              – Ahmad Hassan
              Nov 9 at 1:24










            • nope, none of the answers worked :(
              – Felipe Lima
              Nov 9 at 1:54
















            • I want within the first p tag.
              – Felipe Lima
              Nov 9 at 1:21










            • Try the above code..
              – Ahmad Hassan
              Nov 9 at 1:24










            • nope, none of the answers worked :(
              – Felipe Lima
              Nov 9 at 1:54















            I want within the first p tag.
            – Felipe Lima
            Nov 9 at 1:21




            I want within the first p tag.
            – Felipe Lima
            Nov 9 at 1:21












            Try the above code..
            – Ahmad Hassan
            Nov 9 at 1:24




            Try the above code..
            – Ahmad Hassan
            Nov 9 at 1:24












            nope, none of the answers worked :(
            – Felipe Lima
            Nov 9 at 1:54




            nope, none of the answers worked :(
            – Felipe Lima
            Nov 9 at 1:54










            up vote
            0
            down vote













            You tried define your style inline, only for the first img?






            share|improve this answer
























              up vote
              0
              down vote













              You tried define your style inline, only for the first img?






              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                You tried define your style inline, only for the first img?






                share|improve this answer












                You tried define your style inline, only for the first img?







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 9 at 2:36









                Aaleeciii

                31




                31




















                    up vote
                    0
                    down vote













                    Try p img
                    //your css
                    .. if that doesn't work then create a fiddle or codepen so we can assist you better.






                    share|improve this answer
























                      up vote
                      0
                      down vote













                      Try p img
                      //your css
                      .. if that doesn't work then create a fiddle or codepen so we can assist you better.






                      share|improve this answer






















                        up vote
                        0
                        down vote










                        up vote
                        0
                        down vote









                        Try p img
                        //your css
                        .. if that doesn't work then create a fiddle or codepen so we can assist you better.






                        share|improve this answer












                        Try p img
                        //your css
                        .. if that doesn't work then create a fiddle or codepen so we can assist you better.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Nov 9 at 2:54









                        Chase Martin

                        114




                        114




















                            up vote
                            0
                            down vote














                            My goal is to keep all the p tags with 16px margin except the first one because there's an image inside of it i'd like to keep 100% width of the container.




                            CSS currently cannot look down into the children of an element and then modify the parent or other elements around it. Everything cascades downward in a nested fashion.



                            In other words it cannot say "There is an image inside this paragraph. I need to now change the style of the paragraph that is holding this image and give it a smaller margin."



                            There are only really going to be two ways to accomplish this.



                            One: You can create a class you manually assign to all the paragraphs that contain an image. So you'd have something like this:



                            .entry-content img, .margin-override
                            margin: 0 0 0 0;



                            Then on your paragraph you'll do like this...



                            <div class="entry-content">
                            <p class="margin-override">
                            <img src="foto.jpg">
                            </p>
                            <p>lorem</p>
                            <p>foo</p>
                            </div>


                            Which will set there to be no margin on your image or the paragraph containing the image.



                            Two: The other option is to use javascript/jQuery to search if a paragraph contains an image and then do an action to modify the margins of that paragraph when an image is found.



                            You say you're doing this for a wordpress theme. Wordpress comes packaged with jQuery by default these days so unless you've overridden that it's already in place for you. The next step would be writing a script for yourself to target these paragraphs and script enqueue if with your theme.



                            Here is a decent tutorial on how to add your own scripts to a wordpress theme.






                            share|improve this answer
























                              up vote
                              0
                              down vote














                              My goal is to keep all the p tags with 16px margin except the first one because there's an image inside of it i'd like to keep 100% width of the container.




                              CSS currently cannot look down into the children of an element and then modify the parent or other elements around it. Everything cascades downward in a nested fashion.



                              In other words it cannot say "There is an image inside this paragraph. I need to now change the style of the paragraph that is holding this image and give it a smaller margin."



                              There are only really going to be two ways to accomplish this.



                              One: You can create a class you manually assign to all the paragraphs that contain an image. So you'd have something like this:



                              .entry-content img, .margin-override
                              margin: 0 0 0 0;



                              Then on your paragraph you'll do like this...



                              <div class="entry-content">
                              <p class="margin-override">
                              <img src="foto.jpg">
                              </p>
                              <p>lorem</p>
                              <p>foo</p>
                              </div>


                              Which will set there to be no margin on your image or the paragraph containing the image.



                              Two: The other option is to use javascript/jQuery to search if a paragraph contains an image and then do an action to modify the margins of that paragraph when an image is found.



                              You say you're doing this for a wordpress theme. Wordpress comes packaged with jQuery by default these days so unless you've overridden that it's already in place for you. The next step would be writing a script for yourself to target these paragraphs and script enqueue if with your theme.



                              Here is a decent tutorial on how to add your own scripts to a wordpress theme.






                              share|improve this answer






















                                up vote
                                0
                                down vote










                                up vote
                                0
                                down vote










                                My goal is to keep all the p tags with 16px margin except the first one because there's an image inside of it i'd like to keep 100% width of the container.




                                CSS currently cannot look down into the children of an element and then modify the parent or other elements around it. Everything cascades downward in a nested fashion.



                                In other words it cannot say "There is an image inside this paragraph. I need to now change the style of the paragraph that is holding this image and give it a smaller margin."



                                There are only really going to be two ways to accomplish this.



                                One: You can create a class you manually assign to all the paragraphs that contain an image. So you'd have something like this:



                                .entry-content img, .margin-override
                                margin: 0 0 0 0;



                                Then on your paragraph you'll do like this...



                                <div class="entry-content">
                                <p class="margin-override">
                                <img src="foto.jpg">
                                </p>
                                <p>lorem</p>
                                <p>foo</p>
                                </div>


                                Which will set there to be no margin on your image or the paragraph containing the image.



                                Two: The other option is to use javascript/jQuery to search if a paragraph contains an image and then do an action to modify the margins of that paragraph when an image is found.



                                You say you're doing this for a wordpress theme. Wordpress comes packaged with jQuery by default these days so unless you've overridden that it's already in place for you. The next step would be writing a script for yourself to target these paragraphs and script enqueue if with your theme.



                                Here is a decent tutorial on how to add your own scripts to a wordpress theme.






                                share|improve this answer













                                My goal is to keep all the p tags with 16px margin except the first one because there's an image inside of it i'd like to keep 100% width of the container.




                                CSS currently cannot look down into the children of an element and then modify the parent or other elements around it. Everything cascades downward in a nested fashion.



                                In other words it cannot say "There is an image inside this paragraph. I need to now change the style of the paragraph that is holding this image and give it a smaller margin."



                                There are only really going to be two ways to accomplish this.



                                One: You can create a class you manually assign to all the paragraphs that contain an image. So you'd have something like this:



                                .entry-content img, .margin-override
                                margin: 0 0 0 0;



                                Then on your paragraph you'll do like this...



                                <div class="entry-content">
                                <p class="margin-override">
                                <img src="foto.jpg">
                                </p>
                                <p>lorem</p>
                                <p>foo</p>
                                </div>


                                Which will set there to be no margin on your image or the paragraph containing the image.



                                Two: The other option is to use javascript/jQuery to search if a paragraph contains an image and then do an action to modify the margins of that paragraph when an image is found.



                                You say you're doing this for a wordpress theme. Wordpress comes packaged with jQuery by default these days so unless you've overridden that it's already in place for you. The next step would be writing a script for yourself to target these paragraphs and script enqueue if with your theme.



                                Here is a decent tutorial on how to add your own scripts to a wordpress theme.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Nov 9 at 3:10









                                Jem

                                396319




                                396319




















                                    up vote
                                    0
                                    down vote
















                                    .entry-content
                                    border: none !important;
                                    padding: 0;

                                    p
                                    margin: 16px 16px 0 16px;

                                    .lafoto
                                    width: 200px;
                                    height: auto;
                                    margin: 0 0 0 0;

                                    <div class="entry-content">
                                    <p>
                                    <img class="lafoto" src="https://i.imgur.com/bfMLLDz.jpg">
                                    </p>
                                    <p>lorem</p>
                                    <p>foo</p>
                                    </div>
                                    and this css:





                                    Just add a class to the image, or an id, its that simple.






                                    share|improve this answer
























                                      up vote
                                      0
                                      down vote
















                                      .entry-content
                                      border: none !important;
                                      padding: 0;

                                      p
                                      margin: 16px 16px 0 16px;

                                      .lafoto
                                      width: 200px;
                                      height: auto;
                                      margin: 0 0 0 0;

                                      <div class="entry-content">
                                      <p>
                                      <img class="lafoto" src="https://i.imgur.com/bfMLLDz.jpg">
                                      </p>
                                      <p>lorem</p>
                                      <p>foo</p>
                                      </div>
                                      and this css:





                                      Just add a class to the image, or an id, its that simple.






                                      share|improve this answer






















                                        up vote
                                        0
                                        down vote










                                        up vote
                                        0
                                        down vote












                                        .entry-content
                                        border: none !important;
                                        padding: 0;

                                        p
                                        margin: 16px 16px 0 16px;

                                        .lafoto
                                        width: 200px;
                                        height: auto;
                                        margin: 0 0 0 0;

                                        <div class="entry-content">
                                        <p>
                                        <img class="lafoto" src="https://i.imgur.com/bfMLLDz.jpg">
                                        </p>
                                        <p>lorem</p>
                                        <p>foo</p>
                                        </div>
                                        and this css:





                                        Just add a class to the image, or an id, its that simple.






                                        share|improve this answer















                                        .entry-content
                                        border: none !important;
                                        padding: 0;

                                        p
                                        margin: 16px 16px 0 16px;

                                        .lafoto
                                        width: 200px;
                                        height: auto;
                                        margin: 0 0 0 0;

                                        <div class="entry-content">
                                        <p>
                                        <img class="lafoto" src="https://i.imgur.com/bfMLLDz.jpg">
                                        </p>
                                        <p>lorem</p>
                                        <p>foo</p>
                                        </div>
                                        and this css:





                                        Just add a class to the image, or an id, its that simple.






                                        .entry-content
                                        border: none !important;
                                        padding: 0;

                                        p
                                        margin: 16px 16px 0 16px;

                                        .lafoto
                                        width: 200px;
                                        height: auto;
                                        margin: 0 0 0 0;

                                        <div class="entry-content">
                                        <p>
                                        <img class="lafoto" src="https://i.imgur.com/bfMLLDz.jpg">
                                        </p>
                                        <p>lorem</p>
                                        <p>foo</p>
                                        </div>
                                        and this css:





                                        .entry-content
                                        border: none !important;
                                        padding: 0;

                                        p
                                        margin: 16px 16px 0 16px;

                                        .lafoto
                                        width: 200px;
                                        height: auto;
                                        margin: 0 0 0 0;

                                        <div class="entry-content">
                                        <p>
                                        <img class="lafoto" src="https://i.imgur.com/bfMLLDz.jpg">
                                        </p>
                                        <p>lorem</p>
                                        <p>foo</p>
                                        </div>
                                        and this css:






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Nov 9 at 3:15









                                        Jose Manuel Zuñiga Moreno

                                        207




                                        207




















                                            up vote
                                            0
                                            down vote













                                            There are many possible ways of doing it. First of all I would like to know why you are displaying the image nested within




                                            Try this :- Instead of giving margin to P tag, assign margin to img tag, it will resolve your problem.






                                            share|improve this answer
























                                              up vote
                                              0
                                              down vote













                                              There are many possible ways of doing it. First of all I would like to know why you are displaying the image nested within




                                              Try this :- Instead of giving margin to P tag, assign margin to img tag, it will resolve your problem.






                                              share|improve this answer






















                                                up vote
                                                0
                                                down vote










                                                up vote
                                                0
                                                down vote









                                                There are many possible ways of doing it. First of all I would like to know why you are displaying the image nested within




                                                Try this :- Instead of giving margin to P tag, assign margin to img tag, it will resolve your problem.






                                                share|improve this answer












                                                There are many possible ways of doing it. First of all I would like to know why you are displaying the image nested within




                                                Try this :- Instead of giving margin to P tag, assign margin to img tag, it will resolve your problem.







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Nov 9 at 3:16









                                                Ashish Rathi

                                                126




                                                126



























                                                    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.





                                                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                    Please pay close attention to the following guidance:


                                                    • 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%2f53218426%2fhow-to-select-an-img-after-the-first-p-tag-with-css%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

                                                    𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                                                    How do I collapse sections of code in Visual Studio Code for Windows?

                                                    Node.js puppeteer - Use values from array in a loop to cycle through pages