IE Is Being Mean to Me: Episode 2 – Uppercase HTML Tag

It’s my mistake again. It’s morning and I realized my little code as shown below did not work properly on IE 7 and IE8.

var i = $('#someStuff').html().indexOf("<a>");

It turns out that in IE 7 and IE 8, the HTML tags returned by .html() are all in uppercase. Thus the result is not as expected. Luckily, this is not the case anymore in the latest version, IE 10. So, in order to solve the problem, the code has to be modified to be as follows by converting the result to have lowercase.

var i = $('#someStuff').html().toLowerCase().indexOf("<a>");

Actually this is an known issue in older version of IE. It’s just that I forgot about it.

Meanwhile, I also found some interesting articles about this.

In the past, there were people having a debate on whether the weird behavior of innerHTML or html() in IE 7/8 is a feature or bug. For example, there is a discussion on this in 2008: Bug of Feature – Live .innerHTML in IE.

Currently, XHTML1.0 is still an implemented standard in most of the Internet browsers. In XHTML 1.0: The Extensible HyperText Markup Language (Second Edition), it points out that XHTML documents must use lower case for all HTML element and attribute names. This difference is necessary because XML is case-sensitive e.g. <li> and <LI> are different tags.

For CSS, even though its syntax is not case-sensitive, since element names are not under the control of CSS, the element names used in CSS are also case-sensitive in XHTML (but not HTML).

Anyway, I would like to thank Microsoft engineers for making IE 10 to do the right things. Here is a promo video of IE 10.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s