In my website I have a section where I generate HTML from a twitter feed. Here is the php code that wraps the section in HTML:
<p class="columns">
<?
require ("twitter-feed.php");
echo generatetwitter();
?>
</p>
the generatetwitter(); method returns this as a string:
<li class="twitter">“@<a class=" " href="http://twitter.com/lecrae">lecrae</a>: If people throw stones at you, pick em up and build something. <a href="http://search.twitter.com/search?q=%23stayfocused" title="#stayfocused" class=" ">#stayfocused</a>”</li>
When the page generates it shows the code properly in the “View Source” option of Chrome and Firefox, but when I do “inspect element” it shows this
<p class="columns"></p>
<li class="twitter">...</li>
<p></p>
So the class CSS isn’t getting applied to the twitter feed. I need the twitter feed to be in the p tags with the class defined.
Some points:
- generatetwitter() returns the HTML in a string
- I’ve tried having twitter-feed.php (the generatetwitter() method) echoing out the HTML directly, but it makes no difference. I’ve had the same results every time.
- when the generatetwitter() method is overridden to return only a normal string “eg return “test”;” it works normally.
- It seems that this doesn’t work if the generatetwitter() method returns anything but regular text (excluding HTML).
Certain block level tags will close opened paragraph tags when nested, try using DIV or SPAN instead of the P tag as per my earlier comments.
Nesting block level elements inside the <p> tag… right or wrong?