views:

85

answers:

2

I have problem with validation such code

function show_help_tip(event, element) {

  var $e = $(element);

  var pos = $e.offset();

  $('.body-balloon',$help_tip_div).html($(' <p>&nbsp;</p> ').html(element.getAttribute('title')));

  $help_tip_div.css({position:'absolute',top:530,left:pos.left+$e.width()-20}).show();

}

end tag for element "P" which is not open

What's wrong?

A: 

<p> does not need an end tag. You can use <p>, and I think you can use <p/> if you are OCD or using XHTML, but that mark does not have any content so no end tag.

MJB
The `<p>` tag was a separator in the first couple of versions of HTML, but it became an element with content when HTML was defined in terms of SGML (and you couldn't validate it with an SGML validator before then, so that can't be the problem here!).
David Dorward
I see. No wonder I was confused.
MJB
I don't feel like digging back any earlier, but it was defined as having content in HTML 2 in 1995, so I'm impressed you remember that far back.
David Dorward
What can I say? I am old.
MJB
+2  A: 

You need to escape the / to stop it terminating the script element.

"<\/p>"

The validator should link (via a couple of steps) to http://www.htmlhelp.com/tools/validator/problems.html#script

This is an oddity of SGML, in which an element defined as containing CDATA (such as a script element) will be terminated by any end tag, but if that end tag doesn't match the start tag, then it is invalid.

In a JavaScript string, "/" and "\/" are equivalent, but in HTML </p> and <\/p> are not, so this lets you avoid having something that appears (to the HTML parser) to be an end tag in your script.

David Dorward
THANKS A LOT!IT'S WORKS!
Andrew Spilak