Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJeremy Frimond
14,470 PointsHelp with formatting an img float with text on WP page
I am coding from scratch (HTML and CSS) a specific page within my website http://frimond-design.com/?page_id=108
If you follow the link you will see an image with some text underneath. I am trying to float the image left and have the text wrap down the right. I can create this format without any problems with my text editor and in the browser. When I plug the code into WP my desired format is lost.
I have coded it several different ways with no luck. I know the theme is interfering somewhere but Im stuck. this is what I am after http://imgur.com/6jcJBZK
5 Answers
Riley Hilliard
Courses Plus Student 17,771 Pointsstyle.css on line 279 is adding a clear to your h4 tag. This is preventing it from wrapping around the img tag.
Along with that, wordpress will (annoyingly) auto insert < p > tags at any empty space you have in the post. This isn't technically causing the issue you are seeing, but it can cause formatting issues that are sometimes puzzling to track down when trying to write custom HTML and CSS into wordpress posts & pages. I usually fix this by using the RAW HTML plugin, to fix wordpress' stupid auto HTML generators.
Riley Hilliard
Courses Plus Student 17,771 PointsThe email issue is actually the second part of my answer. Your wordpress is auto wrapping the content above in a < p > tag, and since the address tag is outside the p tag, and the p tag is containing the image and text content, the address tag will not collapse to the right of the image.
<div class="splash-photo">
<p>
<a href="http://frimond-design.com/?page_id=143"><img src="http://frimond-design.com/wp-content/uploads/2014/01/elegant-150x150.jpg" alt="Kristin Walovich" width="150" height="150"></a>
</p>
<p>
<a href="http://frimond-design.com/?page_id=143" title="Kristin Walovich">Kristin Walovich</a>
</p>
<p>
<strong>Analyzing the relationship between tropich position and mercury concentration in deep sea shark species from the Southern Indian Oceans</strong>
</p>
<p>
</p><address>
<a href="mailto:kwalovich@mlml.calstate.edu">Email</a>
</address>
<p></p>
</div>
See all the < p > tags being inserted? your code should look like:
<div class="splash-photo">
<img src="http://frimond-design.com/wp-content/uploads/2014/01/elegant-150x150.jpg" alt="Kristin Walovich" width="150" height="150">
<a href="http://frimond-design.com/?page_id=143" title="Kristin Walovich">Kristin Walovich</a>
<p><strong>Analyzing the relationship between tropich position and mercury concentration in deep sea shark species from the Southern Indian Oceans</strong></p>
<a href="mailto:kwalovich@mlml.calstate.edu">Email</a>
</div>
Your CSS file is located at: /wp-content/themes/catch-everestchild/style.css. You removed the h4 tag, so that isnt an issue anymore, but you should be able to use an h4 if you wanted to, you just needed to override the 'clear' rule in that CSS file at line 279.
Jeremy Frimond
14,470 PointsRiley Hilliard thanks for the help. I removed the clear fix I had place on the H4 however I didn't experience much of a change. I then removed the H4 tags and an almost there. If the email link followed the other two components I would be golden.
How did you find line 279 on the style.css and is that the child theme CSS or the template theme CSS where the clear is?
Cheers
James Anwyl
Full Stack JavaScript Techdegree Graduate 49,960 PointsJust to add the < address > tag is given display: block by default, you could remove this tag and just use < a > to keep the email inline with the rest of the content. (use < br > to put it on its own line)
The line Riley is referring to is found in /wp-content/themes/catch-everest/style.css
Also are you using developer tools? They are extremely useful for seeing what's going on your page and most browsers will have their own version. E.g If your using chrome, ie or firefox press F12 to bring it up. I'm assuming that is how Riley found the problem.
Hope this helps! EDIT: Formatting
Jeremy Frimond
14,470 PointsLegendary Riley Hilliard thanks for the information! I dont know why I had so many <p> tags. The new code does the job and is much more concise.
To confirm, when overriding a css 'clear' property I would the default property of 'none'
Thanks again!