1

This is a problem which is hard to explain without actually showing the problem.

We start off with view-source: View-source

Everything should be inside < p> but instead it closes < p>.

My code:

<p>'.bbCode($Posts['content'], $Posts['id']).'</p>';

and also the preg_replace creating the quote:

$text = preg_replace('/\[quote=([^\]]+)?\]/is', '<div class="quote"><strong>$1 skrev:</strong><br />', $text);
$text = preg_replace('/\[quote[^\]]+\]/is', '<div class=\"quote\"><br />', $text);
$text = preg_replace('/\[\/quote\]/is', '<br clear=\"all\" /></div>', $text);
TheMeisterSE
  • 541
  • 1
  • 7
  • 28
  • 5
    My guess is that your HTML is invalid (e.g. `
    ` inside a `

    `) and the browser is trying to correct it. Post the rendered HTML please.

    – j08691 Jul 21 '15 at 14:40
  • 1
    `

    ` can only contain inline elements. See - http://stackoverflow.com/questions/8397852/why-p-tag-cant-contain-div-tag-inside-it

    – sbeliv01 Jul 21 '15 at 14:40
  • @sbeliv01 how is that relevant to this question? – timo Jul 21 '15 at 14:41
  • Updated guidelines for html5: http://www.w3.org/TR/html5/ (answer in sbeliv01's answer is for html4) – Pete Jul 21 '15 at 14:42
  • 3
    @user1129884 It explains why the browser renders the `

    ` tag as noted.

    – sbeliv01 Jul 21 '15 at 14:42
  • @sbeliv01 I always thought browsers were more forgiving on invalid html, it apears the browser does indeed try to correct this behaviour. http://jsfiddle.net/LLa6yLvg/ – timo Jul 21 '15 at 14:45

2 Answers2

0

Use span instead of div.

<span class="makeSomeCoolFormattedText"> My Awesome Text </span>
Bryan Mudge
  • 432
  • 4
  • 12
0

Browser is trying to correct the invalid markup. You are trying to insert some block elements into p. Two solutions: change p to section, article or div or something else OR strip posts from html markup.

boszlo
  • 1,144
  • 10
  • 14