Why does password boxes are smaller than text boxes in IE ?

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′ “.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


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.

  1. Solution using jQuery: The jQuery code is included in the page load. Make equal-width of text and password input control boxes using jQuery.



    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
      
    <head>
      <meta charset="UTF-8">
      <title>GeeksforGeeks</title>
      
      <script src=
        integrity=
    "sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
        crossorigin="anonymous">
      </script>
        
      <script type="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>
          <input type="text">
          <br>
          <label>PASSWORD INPUT:</label>
          <br>
          <input type="password">
        </p>
      </form>
    </body>
      
    </html>

    chevron_right

    
    

    or

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
      
    <head>
      <meta charset="UTF-8">
      <title>GeeksforGeeks</title>
      
      <script src=
        integrity=
    "sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
        crossorigin="anonymous">
      </script>
        
      <script type="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>
          <input type="text">
          <br>
          <label>PASSWORD INPUT:</label>
          <br>
          <input type="password">
        </p>
      </form>
    </body>
      
    </html>

    chevron_right

    
    

  2. 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.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
      
    <head>
      <meta charset="UTF-8">
      <title>GeeksforGeeks</title>
      <style type="text/css">
        input {
          width: 14em;
        }
      </style>
    </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>

    chevron_right

    
    

  3. By setting the default font family for inputs: (Most liked solution) This method uses same font family for all the inputs.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
      
    <head>
      <meta charset="UTF-8">
      <title>GeeksforGeeks</title>
      <style type="text/css">
        input {
          font-family: sans-serif;
        }
      </style>
    </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>

    chevron_right

    
    

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.