I am trying to add <body>, <head>, <html> into <code> tag but it does not consider it as its HTML. Other Tags like <div>, <a>, <p>, <b>, <i>, <textarea> e.t.c are working.
Here is the Fiddle:
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
<html>,<body>, and<head>are expected to be the root of the document, so they will be ignored when they are not at the root.When you add
<code>at the root, the browser inserts<html><body>before it automatically because it knows it is supposed to be there, and then it will ignore the others because they are not at the root.That means that what actually ends up in the parsed DOM tree is this:
Thus, when your code runs, it gets everything inside of
<code>.If you want to display all if this as text, you should be encoding the HTML as text, using
<and such, and then use.text()instead.Like this: http://jsfiddle.net/eqnK4/1/