Reputation: 7599
i'm having the following php code:
$html = '<p>[tag]</p>';
$test = "<a href='#'><div class='test'>button</div></a>";
$html = str_replace("[tag]", $test, $html);
when using echo htmlentities($html) i'm getting the expected result:
<p><a href='#'><div class='test'>button</div></a></p>
but when echoing the $html, firefox renders it like this:
<p>
<a href="#"></a>
</p>
<div class="test">
<p></p>
which is very strange .. any ideas what's wrong?
thanks
EDIT: i found out that it's only wrong when checking with firebug. when displaying the browser's source, it show's up as expected. nevertheless, to the browser it seems to be invalid html markup ..
Upvotes: 0
Views: 111
Reputation: 1
Please do me a favor: replace the div element with span and it will work.
Reasons:
Do That And You are good to go :D
Upvotes: 0
Reputation: 25945
I believe it's because you can't have block level elements inside inline elements. Similar to that you can't put a <p>
tag inside a <span>
tag.
HTML 4.01 specifies that
<a>
elements may only contain inline elements. A<div>
is a block element, so it may not appear inside an<a>
.
Upvotes: 1
Reputation: 288
maybe you're showing "selected source code". In firefox, the selected source code is modified version with the standart usage rules. You can show retrieved DOM by using show page source.
Upvotes: 0