Tips for achieving consistent outcomes on both IE and Chrome when utilizing the `min` attribute in HTML input tags

The display of input fields is inconsistent between IE (version 11) and Chrome (version 46.0.2490.71) when using the min option in the HTML input tag. In Chrome, the input fields appear extra long, while in IE they display correctly (same as when min is not used).

To observe this inconsistency, please open the HTML file in IE as jsfiddle will always show the unwanted longer input fields.

Here is a link to the sample jsfiddle: min demo

Is there a solution you can suggest to achieve consistent display on both IE and Chrome while using min in the HTML input type="number"?

HTML Code:

<html>
    <head>
        <title>CommDesk AdminPage</title>
        <meta HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                addPlusSign();
                $(".btn1").click(function(){
                    $(".expand1").toggle();
                    var btn1Text = $(".btn1").text();
                    if(btn1Text.indexOf("+") > -1){
                        var temp = btn1Text.replace(/\+|\-/ig, '-');
                        $(".btn1").text(temp);
                    } else if (btn1Text.indexOf("-") > -1){
                        var temp = btn1Text.replace(/\+|\-/ig, '+');
                        $(".btn1").text(temp);
                    }
                });
            })
            function addPlusSign(){
                if($(".expand1")){
                    var btn1Text = $(".btn1").text();
                    $(".btn1").text(btn1Text + " [+]");
                }
            }
            $(function () {
                $('.admin-form')
                //we need to save values from all inputs with class 'admin-input'
                .find(':input.admin-input')
                .each(function () {
                    //save old value in each input's data cache
                    $(this).data('oldValue', $(this).val())
                })
                .end()
                .submit(function (ev) {
                    var changed = false;
                    $(':input.admin-input', this).filter(function () {
                        if($(this).val() != $(this).data('oldValue')){
                            changed = true;
                        }
                    });
                    if($(this).hasClass('changed') && (!changed)){
                        alert("None of the thresholds were changed!");
                        ev.preventDefault()
                    }
                    if($(this).hasClass('changed') && changed){
                        var allowSubmit = window.confirm("You have set a unique threshold for one or more sub-elements below. Are you sure you want to reset them all?")
                        if (!allowSubmit)
                        ev.preventDefault()
                    }
                });
            });
            $(document).on('input', '.admin-input', function(){
                $(this).closest('form').addClass('changed');
            });
        </script>

        <style>
        .expand1 { display: none;
        }
        .btn1 { cursor: pointer;
        }
        body {
        background-color: rgb(255,255,255);
        font: 15px Verdana, Helvetica, sans-serif;
        }

        table#t02, #t02 th, #t02 td {
            border: none;
            border-collapse: collapse;
            font-size:90%;
            font-weight:normal;
        }

        #button1{
            position: relative;
            top:10px;
            left:75%;
            color: white;
            background-color: rgb(0,89,132);
            font-weight: bold;
        }
        </style>

    </head>
    <body>
        <form id="form1" method="post" class="admin-form">
            <div style="float:left; width:50%">
                <table id="t02" class="table2">
                    <tr>
                        <th style="padding:0 30px 0 0;"></th>
                        <th></th>
                        <th style="padding:0 10px 0 0;">Green</th>
                        <th colspan="3" style="padding:0 10px 0 0">Yellow</th>
                        <th></th>
                        <th style="padding:0 10px 0 0">Red</th>
                    </tr>
                    <tr>
                        <td class="btn1" style="padding:0 30px 0 0;"><b>Call Volume</b></td>
                        <td>&lt</td>
                        <td style="padding:0 10px 0 0"><input type="number", class="admin-input", name="acd_call_volume_good_high", min="0", value="50"></td>
                        <td><input type="number", class="admin-input", name="acd_call_volume_warning_low", min="50", value="50"></td>
                        <td>to</td>
                        <td style="padding:0 10px 0 0"><input type="number", class="admin-input", name="acd_call_volume_warning_high", min="50", value="100"></td>
                        <td>&gt</td>
                        <td style="padding:0 10px 0 0"><input type="number", class="admin-input", name="acd_call_volume_critical_low", min="100", value="100"></td>
                    </tr>
                    <tr>
                        <td align="center" class="expand1">Day of Job (DOJ)</td>
                        <td class="expand1">&lt</td>
                        <td class="expand1"><input type="number", name="acd_call_volume_good_high_Day of Job (DOJ)", min="0", value="50"></td>
                        <td class="expand1"><input type="number", name="acd_call_volume_warning_low_Day of Job (DOJ)", min="50", value="50"></td>
                        <td class="expand1">to</td>
                        <td class="expand1"><input type="number", name="acd_call_volume_warning_high_Day of Job (DOJ)", min="50", value="100"></td>
                        <td class="expand1">&gt</td>
                        <td class="expand1"><input type="number", name="acd_call_volume_critical_low_Day of Job (DOJ)", min="100", value="100"></td>
                    </tr>
                </table>
                <input type="submit" name="submitButton" value="Submit" id="button1" style="height:50px; width:100px"/>
            </div>
        </form>
    </body>
</html>

CSS:

.expand1 { display: none;
}
.btn1 { cursor: pointer;
}
body {
background-color: rgb(255,255,255);
font: 15px Verdana, Helvetica, sans-serif;
}

table#t02, #t02 th, #t02 td {
border: none;
border-collapse: collapse;
font-size:90%;
font-weight:normal;
}

#button1{
position: relative;
top:10px;
left:75%;
color: white;
background-color: rgb(0,89,132);
font-weight: bold;
}

Answer №1

When utilizing the min option in an HTML input tag, there may be inconsistencies in the visual display.

The purpose of the min attribute for number inputs is to define the minimum value that a user can input, not to control the size or width of the input field.

To restrict the maximum width of these input fields, you should utilize the max-width property in your CSS stylesheet:

input[type=number] {
  max-width: 100px;
}

Note that setting a max-width does not ensure that the input fields will always be at least 100px wide. If you require them to maintain a specific width, use the width property instead.

Also, avoid using commas to separate attributes within the input tags.

If possible, consider using CSS for layout purposes rather than relying on tables. However, the provided solution should address the issue raised in your query. You might want to explore resources on flexbox if you opt to transition away from table layouts.

You can find a runnable snippet below for reference:

{/* Runnable snippet code here */}

Sources:

http://www.w3.org/TR/html5/forms.html#the-min-and-max-attributes

https://developer.mozilla.org/en-US/docs/Web/CSS/max-width

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Looking to achieve a mouse over effect in jQuery?

For the past few days, I've been grappling with a question that I just can't seem to find the right answer to. I'm trying to create a mouseover effect similar to the one on this template (the Buddha at the top of the page). Despite my best e ...

Change wiki text into HTML using Python for showcasing on a webpage

Despite trying various tools for 6 hours, I have been unable to find one that can properly interpret wikitext like the example below: '<center>Welcome to the world's foremost open content<br><big><big><big>'&ap ...

Eliminate styling from text within an HTML document

I'm currently working on removing text decorations from my text. I managed to remove the underline, but when I hover over the text, the color still appears. How can I get rid of this color as well? Take a look at the code below: messbox { backgr ...

Improving Vue Component on Navigation

I am facing an issue with my navbar where I have two versions. Version 1 features a white text color, while Version 2 has black text. The need for two versions arises due to some pages having a white background, hence the requirement for black text. Bot ...

Creating an Angular form from scratch using HTML

I've developed a component named login. Initially, I created an HTML form called login.component.html and then decided to convert it into an Angular form. To achieve this, I inserted <form #loginform="ngForm"> in the login.component.ht ...

ScrollReveal.js won't function as intended

https://i.stack.imgur.com/SOQEk.png Looking to utilize the popular ScrollReveal.js created by Julian Lloyd (ScrollReveal) Despite following instructions from various sources, the script is not producing the intended effect. Steps taken to make it work: ...

Extract value from child div using JQuery and update text in another section of the page

Here is a fiddle showcasing the concept I am working on: https://jsfiddle.net/wvz9p3e7/1/ The code is written in PHP and involves a loop for cycling through 7 or 8 different garments. My goal is to have the window on the right side of the fiddle display t ...

Instructions on integrating a column of buttons into a Bootstrap table containing information retrieved from a MySQL database

My bootstrap table is currently displaying data that is loaded from a MySQL database. I am looking to enhance it by adding a column with buttons, similar to the layout shown in this image. https://i.stack.imgur.com/8fWfR.png However, I am facing some dif ...

The font rendering in Safari appears to have distinct differences compared to other web browsers

My concern is related to the HTML tag below: <a href="/partner-team/team" class="button button__style--1">MEHR</a> This is how the CSS appears: a { text-decoration: none; } .button { padding: 0.2rem 4rem; curso ...

There seems to be a white space problem located beneath the header photo and the initial

I'm a beginner at coding and working on this project for fun. I'm almost done, but I can't get rid of a white space that's dividing my header from the first section. See the screenshot below: https://i.stack.imgur.com/a1flt.png Even af ...

Having trouble with displaying the results of JQuery Ajax in Chrome?

I am facing a compatibility issue between IE 8 and Chrome 16.0.912.77 with the following code. Any suggestions? <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(fu ...

"Implementing a button in a flask data table: A step-by-step guide

Hello, I am facing an issue with adding a button to a Bootstrap datatable in Flask (Python) using JavaScript. Any tips or solutions would be greatly appreciated. I am trying to achieve something like this: I have attempted to return the button with JSON d ...

React Bootstrap's drop-down components with a dark theme

In my react application, I am looking to design a custom navbar for the header using react-bootstrap. Specifically, I need a dark styled NavDropdown that changes background color to #f0ad4e on hover. Despite attempting the following code snippet, I couldn& ...

What is the proper way to utilize CSS animation delays in order to design a collapsible HTML container?

I'm trying to implement responsive CSS animation delay to create an accordion effect when a user clicks on an arrow associated with a table, all without using JavaScript and only utilizing HTML/CSS. Check out the mobile view in action here: https://w ...

What is the best way to extract multiple children from a shared tag using BeautifulSoup?

My current project involves using BeautifulSoup to scrape thesaurus.com for quick access to synonyms of specific words. However, I've run into an issue where the synonyms are listed with different ids and classes for each word. My workaround is to tar ...

obtain the text content from HTML response in Node.js

In my current situation, I am facing a challenge in extracting the values from the given HTML text and storing them in separate variables. I have experimented with Cheerio library, but unfortunately, it did not yield the desired results. The provided HTML ...

Is it possible to create a masonry-style layout with two columns that is responsive without

Is there a way to organize multiple divs of varying heights into two columns that display immediately one after the other, without relying on JavaScript or libraries like packery or masonry? I've experimented with using display: inline-block in this ...

Verify if any choices are available before displaying the div block

I need to determine if there is a specific option selected in a dropdown menu, and then display a div if the option exists, otherwise hide it. I'm not just checking the currently selected option, but all available options. if (jQuery(".sd select opti ...

Tips on achieving horizontal scrolling for div overflow instead of wrapping onto a new line

It's a frequent occurrence in mobile apps to have a navbar with selectable text options that overflow horizontally without breaking into a new line. Instead, users must scroll horizontally to access all the options available. Is there a way for me to ...

Unique ways to serialize an HTML element efficiently: JavaScript tricks

Is there a way to store a reference of an HTML tag for future use? For instance, if I click on a div and save a pointer to that div in JavaScript, is it possible to serialize this pointer and then de-serialize it to use in another part of the web applicat ...