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
html css
|
show 2 more comments
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
html css
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:containsdoesn'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
|
show 2 more comments
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
html css
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
html css
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:containsdoesn'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
|
show 2 more comments
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:containsdoesn'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
|
show 2 more comments
7 Answers
7
active
oldest
votes
up vote
0
down vote
.entry-content p>img
// your css
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
add a comment |
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
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
add a comment |
up vote
0
down vote
You tried define your style inline, only for the first img?
add a comment |
up vote
0
down vote
Try p img .. if that doesn't work then create a fiddle or codepen so we can assist you better.
//your css
add a comment |
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.
add a comment |
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.
add a comment |
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.
add a comment |
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
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
add a comment |
up vote
0
down vote
.entry-content p>img
// your css
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
add a comment |
up vote
0
down vote
up vote
0
down vote
.entry-content p>img
// your css
.entry-content p>img
// your css
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
add a comment |
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
add a comment |
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
up vote
0
down vote
You tried define your style inline, only for the first img?
add a comment |
up vote
0
down vote
You tried define your style inline, only for the first img?
add a comment |
up vote
0
down vote
up vote
0
down vote
You tried define your style inline, only for the first img?
You tried define your style inline, only for the first img?
answered Nov 9 at 2:36
Aaleeciii
31
31
add a comment |
add a comment |
up vote
0
down vote
Try p img .. if that doesn't work then create a fiddle or codepen so we can assist you better.
//your css
add a comment |
up vote
0
down vote
Try p img .. if that doesn't work then create a fiddle or codepen so we can assist you better.
//your css
add a comment |
up vote
0
down vote
up vote
0
down vote
Try p img .. if that doesn't work then create a fiddle or codepen so we can assist you better.
//your css
Try p img .. if that doesn't work then create a fiddle or codepen so we can assist you better.
//your css
answered Nov 9 at 2:54
Chase Martin
114
114
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 9 at 3:10
Jem
396319
396319
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
.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:answered Nov 9 at 3:15
Jose Manuel Zuñiga Moreno
207
207
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 9 at 3:16
Ashish Rathi
126
126
add a comment |
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.
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.
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%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
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
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:containsdoesn'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