According to Microsoft, whenever Internet Explorer provides the HTML page structure, it uses the wrong character set even after providing the correct character set by the META tag.
HTML part of user input: The following HTML code shows the general password input form which works fine in Google Chrome, Firefox, Microsoft Edge but not in IE. The widths of the input boxes are different in case of IE even if we are specifying “ charset=’UTF-8′ “.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>GeeksforGeeks</title> </head> <body> <form> <p> <label>TEXT INPUT:</label> <br> <input type="text"> <br> <label>PASSWORD INPUT:</label> <br> <input type="password"> </p> </form> </body> </html> |
Note: The causes for this abnormal behavior of IE are specified in the documentation with the link below.
https://support.microsoft.com/en-us/help/928847/internet-explorer-uses-the-wrong-character-set-when-it-renders-an-html
Solution: It is known that there is some issue with the IE’s default character set.
Let us look into some solutions which are used to overcome this problem.
-
Solution using jQuery: The jQuery code is included in the page load. Make equal-width of text and password input control boxes using jQuery.
<!DOCTYPE html><html><head><metacharset="UTF-8"><title>GeeksforGeeks</title><scriptsrc=integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="crossorigin="anonymous"></script><scripttype="text/javascript">$(document).ready(function () {$("input[type='text']").height($("input[type='password']").height());$("input[type='text']").width($("input[type='password']").width());});</script></head><body><form><p><label>TEXT INPUT:</label><br><inputtype="text"><br><label>PASSWORD INPUT:</label><br><inputtype="password"></p></form></body></html>chevron_rightfilter_noneor
<!DOCTYPE html><html><head><metacharset="UTF-8"><title>GeeksforGeeks</title><scriptsrc=integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="crossorigin="anonymous"></script><scripttype="text/javascript">$(document).ready(function () {$("input[type='password']").height($("input[type='text']").height());$("input[type='password']").width($("input[type='text']").width());});</script></head><body><form><p><label>TEXT INPUT:</label><br><inputtype="text"><br><label>PASSWORD INPUT:</label><br><inputtype="password"></p></form></body></html>chevron_rightfilter_none -
Solution using CSS: Fix the width of both the input controls to some value depending on your project. Here “14em” width is used, just change this to the value of desired width.
<!DOCTYPE html><html><head><metacharset="UTF-8"><title>GeeksforGeeks</title><styletype="text/css">input {width: 14em;}</style></head><body><form><p><label>TEXT INPUT:</label><br><inputtype="text"><br><label>PASSWORD INPUT:</label><br><inputtype="password"></p></form></body></html>chevron_rightfilter_none -
By setting the default font family for inputs: (Most liked solution) This method uses same font family for all the inputs.
<!DOCTYPE html><html><head><metacharset="UTF-8"><title>GeeksforGeeks</title><styletype="text/css">input {font-family: sans-serif;}</style></head><body><form><p><label>TEXT INPUT:</label><br><inputtype="text"><br><label>PASSWORD INPUT:</label><br><inputtype="password"></p></form></body></html>chevron_rightfilter_none
Recommended Posts:
- How to Sign In with raw password when password store in the database are hashed form in Node.js ?
- How to compare password and confirm password inputs using express-validator ?
- Why does sizeof(x++) not increment x in C?
- Why does AngularJS include an empty option in select ?
- Why PHP script does not create a directory with 777 permissions ?
- Why does PHP 5.2+ disallow abstract static class methods ?
- Why does canvas.toDataURL() throws a security exception?
- Why does SASS cache folder is created ?
- Why Transition properties does not work with display properties ?
- How to insert collapsible Text Boxes in New Google Sites ?
- How to set smaller text using HTML5 ?
- Why are elementwise additions much faster in separate loops than in a combined loop?
- Why Linux Hosting is Cheaper than Windows Hosting ?
- Why is === faster than == in PHP ?
- How to select all text in HTML text input when clicked using JavaScript?
- Text Animation with changing the color of the text using HTML & CSS
- How to create long shadow of text without using text-shadow in HTML and CSS ?
- JavaScript | Dialogue Boxes
- AngularJS | Select Boxes
- ES6 | Dialog Boxes
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


