I'm using the IE 11 (version 11.0.9431.0), to test our current website and see how it would work when IE 11 will be released with Windows 8.1 mid-October.
What I see on almost all pages is the following message:
HTML1514: Extra "<body>" tag found. Only one "<body>" tag should exist per document.
When I look through the source code, there is no second <body> anywhere. Is this a IE 11 bug? Is this something I should take seriously? The pages work fine btw...
Thanks.
EDIT:
I don't have access to that website anymore, therefore I can't try any new solutions you guys are posting.
If you placed some element (that should appear only inside body) before the <body> tag, the <body> is inserted automatically by the parser (the "Anything else" paragraph) - and this is still valid HTML because body has optional both opening and closing tags. That would mean that the actual <body> is the second one the parser sees. Couldn't this be your case?
My guess is you probably have if IE statements, something like:
<!--[if IE 9]> <body class="ie ie9 lte9"> <![endif]-->
They don't actually work in IE10, let alone IE11 so that's why you'd be getting the extra tag found.
The problem (which is present in IE 10, too) is caused by the element
<script type="text/javascript" src="/_clients/binck_nl/data/js/analytics.js?nl_1377516473" ></script>
It probably modifies the DOM so that IE gets confused.
it's probably your body tag in the css. Replace the body-tag in the css with a class for example .bodystyle {} and refere in your html to it with the tag. That should do the trick.
Hi this may be a very late for suggesting. But, just to help others the probable cause may be any iframe coming in the page which has body tag
I had this same effect showing up in IE10 and IE11 saying there was an extra body tag in the console. What fixed it for me was that I found an element outside of the body that was a div for a spinner while the page loads that should have been within the body.
My guess is that it may be content in the header part which Edge wants in the body part. (If you have a header part).
This works in any other browser but Edge.
I solved this by removing: <header><title>something</title></header> from the tag body. Now edge no longer complains.
Related
Is it likely or possible for img tag, or any other to be parsed, when the < tag is several characters prior, or perhaps omitted? Would this happen in any notable HTML parsers?
For example
<div>$test</div>.
Where $test could be any string containing a >, but not a <. Such as img>, but not <img
Full disclosure: This question is specifically to see whether or not the comment I posted was correct.
You don't technically need either < or >. Load this up in IE, and it'll run a javascript alert. Not sure if it's possible without messing with the charset though.
<HTML>
<HEAD>
<META charset="UTF-7">
</HEAD>
<BODY>
<DIV>+ADw-script+AD4-alert(+ACI-XSS+ACI-)+ADw-/script+AD4-</DIV>
</BODY>
</HTML>
Source: http://securityoverride.org/articles.php?article_id=13
Well, out of curiosity, I changed one of my test pages so its script section began with this:
< script>
The result was completely broken and just printed all of my javascript. This happened in IE9, GC28, and Firefox. I didn't really have an image on-hand to test with, but I think we can derive from this that HTML tags are always required to have no white-space between the angle bracket and tag declaration.
If you'd like even further confirmation, I suggest you browse the W3C standardization documents to see if you can find where they declare the generic pattern for HTML element tags. Many HTML parsers probably base themselves off those documents to ease their coding.
White space is allowed after the tagname
< script> is invalid
while
<script> is valid
Is there any way that I could display HTML tags without parsing? Tags like XMP worked before perfectly but now it's replaced with PRE that isn't so cool. Take a look at this example:
//This used to NOT PARSE HTML even if you used standard < and >.
<XMP>
<a hred="http://example.com">Link</a>
</XMP>
//New PRE tag requires < and > as replacement for < and >.
<PRE>
<a href="http://example.com">Link</A>
</PRE>
What I'm looking for is equivalent of old XMP tag. New PRE tag will parse code.
You can use a script element with its type set to denote plain text, and set its display property to block. This only affects the parsing behavior: no markup (tags or entity or character references) is recognized, except for the end tag of the element itself </script>. (So it is not quite the same as xmp, where the recognized tag is </xmp>.) You can separately make white space handling similar to that of xmp and pre and/or set the font the monospace as in those elements by default.
Example:
<style>
script {
display: block;
}
</style>
Then within document body:
<script type="text/plain">
<i>é</i>
</script>
Tested on newest versions of IE, Chrome, Firefox, Opera. Didn’t work in IE 8 and IE 7 emulation on IE 9, but that’s probably a bug in the emulation.
However, I don’t see why you would use this instead of xmp, which hasn’t stopped working. It’s not in the specs, but if you are worried about that, you should have always been worried. Mentioned in HTML 2.0 (the first HTML spec ever) as avoidable, it was deprecated in HTML 3.2 and completely removed in HTML 4.0 (long ago: in 1997).
The xmp is making a comeback rather than dying. The W3C HTML5 (characterized as the current HTML specification by W3C staff) declares xmp as obsolete and non-conforming, but it also imposes a requirement on browsers: “User agents must treat xmp elements in a manner equivalent to pre elements in terms of semantics and for purposes of rendering. (The parser has special behavior for this element though.)” The old parsing behavior is thus not explicitly required, but clearly implied.
I personally think using the <code> </code> tags only works in Dream Weaver and the tag <xmp> </xmp> never stopped working unless you put in </xmp> it works fine. Using <textarea> </textarea> makes it so that others can edit your code on the website or the page so I recommend that the tag <xmp> </xmp> is still used and that that tag still lives on.
The modern way is to use textarea with (boolean) attribute readonly. You could use XMP, but that is deprecated, so it may eventually stop being supported.
example:
<textarea readonly='true'>
<p>This is some text</p>
</textarea>
And then... a few years go by, I have the same problem while converting my blog from wordpress to a vuejs spa backed by lambda and dynamodb.
And the answer is; at least in my situation. Escape the entity.
< becomes <
> becomes >
etc. etc.
Hope this helps.
There isn't.
In theory you could use a CDATA block, but no browser supports that in text/html mode.
Use character references.
If you want to be more complex, another way is to create a custom tag using jQuery. For this example, I used <noparse>.
$('noparse').each(function(){
if($(this).attr('tagchecked') != 'true'){ //checks if already changed tag
$(this).text($(this).html()).attr('tagchecked', 'true'); //makes the html into plaintext
}
});
JSFiddle here
I suggest using the html iframe tag and put the text you like to display in the src attribute. you only have to url or base64 encode it first.
example (urlencoded):
<iframe src="data:text/plain,%22%3Chello%3E%22"></iframe>
example (base64):
<iframe src="data:text/plain;base64,IjxoZWxsbz4i"></iframe>
Result displayed as:
"<hello>"
Technically you could use <textarea>, but it would require that there be no </textarea> tag in the code you are trying to show. It'd just easier to escape the <.
Well, one way would be to use jQuery. the jQuery .text() method will encode special characters. And the original un-encoded text will remain if you view source.
<div id="text">
This is an anchor
</div>
<script>
var t = $('#text'); t.html(t.text());
</script>
I am reworking some old, hand-crafted HTML. Is the style= attribute doing anything here?
<script type="text/javascript" style="behavior:url(#default#clientcaps)" id="..." src="..."></script>
I find a lot of hits searching for style=behavior:url(#default#clientcaps)}, but will this have any effect on a <script> tag?
style is not a valid attribute on a <script> element (W3C), so it's not doing anything. Even Internet Explorer, which is the only browser that supports CSS behaviors, is ignoring it.
It is some ugly MS stuff.
Provides information about features supported by Windows Internet Explorer, as well as a way for installing browser components on demand.
Try get get to the person who added it and tell him he's a bad guy! ;)
I think in this case the style attribute is used just for a short hand for creating a style tag.
short for:
<STYLE>
#media all {
IE\:clientCaps {behavior:url(#default#clientCaps)}
}
</STYLE>
Its specific to Internet Explorer. For what it does exactly you can read more here:
clientCaps Behavior
Is there ever an instance in which something should (or can?) be placed between the </body> and </html> tag? Or should they always be paired?
I was reading the HTML5 spec, and it got me thinking about the basic structure of a page.
Are there any cases where anything can/should be placed after the </html> tag? It used to be gospel that documents started with just <html>, but <!doctype...> changed that. Would there ever be a reason to change that for the end of a document?
The <body> tag is optional since <frameset> can be used instead. Therefore, they are not always paired. White space can exist between the tags. Also, <body> can come before <head>.
Currently, anything after a closing </html> tag is generally considered inline text. Firefox and IE both render it.
The Document Type Definitions (DTDs) of each style hold the answers you seek.
No, not really. There's no reason to put anything after </html>. After all, you are defining an html document. The DocType was introduced because of inconsistencies in browser rendering.
As for after the body tag. I could one day see "foot" as a tag introduced to match the head at the top. The only thing that I can see it being used for would be javascript that is loaded after the document. Right now, that is just put right before the end of the body tag.
Some people like to put javascripts intended to run after the page has finished loading either at the very bottom of the body section or below the </body> tag. Really though there is no reason to do this if you are using jQuery, since the $(document).ready() function makes it moot.
No structural tags should be there however, and actually JS should be in the <head> section anyway.
Nothing can go after </html> nor between </body> and </html>.
On the other hand, bear in mind that HTML, HEAD and BODY are implied even if the tags don't exist, so an html document does not have to end with </html>.
Of course, browsers tend to try to guess what the author wanted rather than breaking on invalid markup, so yes, you can expect people putting something after </html>, because it does what they want.
Can I use specific html if the browser is IE? (Assuming FF is the default browser)
Foe example:
html line 1
if IE
html line 2
else
html line 2
html line 3
html lin3 4
I am aware of using different CSS, but that won't work for this.
Thanks.
Sure - conditional comments
IE understands "conditional comments," which you can use to selectively show markup even to specific versions. Here's an introduction:
http://www.quirksmode.org/css/condcom.html
I'd like to offer a bit more explanation, since a solution to your question necessarily involves both "downlevel-revealed" and "downlevel-hidden" conditional comments. Both work very well in Internet Explorer, but it's in non-Microsoft browsers that the distinction becomes important:
Content inside "Downlevel-revealed" conditional comments will always display in non-Microsoft browsers (since they do not follow the standard <!-- --> syntax of HTML comments).
Content inside "Downlevel-hidden" conditional comments (which seem to be discussed more often) will never show up in other browsers (since they do follow the standard <!-- --> syntax of HTML comments).
So, marking up your example code:
html line 1
<!--[if IE]>
html line 2
<![endif]-->
<![if !IE]>
html line 2
<![endif]>
html line 3
html lin3 4
You could use conditional comments for code only IE reads:
<!--[if IE]>
IE only code here.
<![endif]-->
Or PHP:
<?php
function ae_detect_ie()
{
if (isset($_SERVER['HTTP_USER_AGENT']) &&
(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
return true;
else
return false;
}
?>
<?php if (ae_detect_ie()) { code here } else { code here } ?>
Ryan
One way you can do this is using Javascript to check which browser is being used. You could have default HTML in your file and then hava Javascript change it out, or add to it, if the user is using IE.