I have the following JS code:
validateConfigName.html('<img src="/rta/images/check-24.png" />');
But when it executes in Firefox I see this as the generated code:
<img src="/rta/images/check-24.png">
Why?
I have the following JS code:
validateConfigName.html('<img src="/rta/images/check-24.png" />');
But when it executes in Firefox I see this as the generated code:
<img src="/rta/images/check-24.png">
Why?
Share Improve this question asked Aug 20, 2010 at 1:27 ashurexmashurexm 6,3354 gold badges48 silver badges71 bronze badges 2- 4 @Thilo - It doesn't...but if I'm hiring a programmer, I'm after the one that does ask why. I wish more people actually cared why something is like it is. – Nick Craver Commented Aug 20, 2010 at 2:30
- 2 @Thilo - Nick is right, it doesn't. Just interested in why I was seeing the discrepancy. I already know that it's not a big deal, but was wondering if anyone with some deeper insight could definitively answer the question. What is SO good for if you can't ask the simple question of why? – ashurexm Commented Aug 20, 2010 at 15:54
4 Answers
Reset to default 6In HTML the <img>
tag is supposed to be <img>
, in XHTML it'll be <img />
...so depending on what DOCTYPE your page is using, this will vary.
From the HTML 4.0 Spec for <img>
:
Start tag: required, End tag: forbidden
In XHTML elements must be closed:
Well-formedness is a new concept introduced by [XML]. Essentially this means that all elements must either have closing tags or be written in a special form (as described below), and that all the elements must nest properly.
Generated code, as in, like Firebug or something? Firebug operates on the DOM and not actual source code which means that it may not look exactly the same as the code you entered. It shouldn't really make a difference, though.
It's because you're not serving XHTML, even if your DOCTYPE is an XHTML doctype. An XHTML document isn't treated as XHTML unless you either serve it as application/xhtml+xml
, application/xml
, or text/xml
using the Content-Type
HTTP header.
It's the way, the browser renders your html code according to the doctype used.
Nothing to worry about though..
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744168464a4561416.html
评论列表(0条)