I am setting the border to 0 in CSS, so why do my inputs still have a border?

Despite setting the border to 0 and border-style to none, I am still seeing a border around my inputs. Even more confusing is that when I try to add a border, the original border appears on top of it. It seems like this issue may be related to the input size being less than 4, but regardless, I would like to remove it entirely or at least set a consistent color if I can't delete the original border.

I have tried various combinations:

  • Setting border to 0
  • Setting border-style to none
  • Setting border-color to white (which had unexpected results)
<div class="time-container" align="center">
    <div id="start" align="middle">

                    <h2 class="start-time">start</h2>

            <div class="time">
                    <form class="hour">
                        <input type="text" size="3" maxlength="3" placeholder="hr">
                    </form>
                    :
                    <form class="min">
                        <input type="text" size="3" maxlength="2" placeholder="min">
                    </form>
                    :
                    <form class="sec">
                        <input type="text" size="3" maxlength="2" placeholder="sec">
                    </form>
            </div>

                    <h3></h3>

    </div>



            <div class="hyphen">
                -
            </div>


    <div id="stop" align="middle">

                    <h2 class="end-time">end</h2>

            <div class="time">
                    <form class="hour">
                        <input type="text" size="3" maxlength="3" placeholder="hr">
                    </form>
                    :
                    <form class="min">
                        <input type="text" size="3" maxlength="2" placeholder="min">
                    </form>
                    :
                    <form class="sec">
                        <input type="text" size="3" maxlength="2" placeholder="sec">
                    </form>
            </div>

                    <h3></h3>
    </div>
</div>



h2 {
    margin-top: 20px;
    border-bottom: 2px solid #ccc;
    padding-bottom: 5px;
    text-align: left;
    color: gray;
    font-size: 16px;
    font-weight: normal;
    width: 131px;
}

.min, .sec, .hour {
    font-family: 'Roboto', sans-serif;
    width: 33px;
    box-sizing: border-box;
    border: 4px solid #ccc;
    font-size: 16px;
    margin: 0;
    padding: 0;
    background: white;
    display: inline-block;
}

h3{
    border-top: 2px solid #ccc;
    width: 131px;
}

.time-container {
    display: flex;
    width: 100%;
    align-self: center;
    justify-content: center;
}

.hyphen {
    color: #ccc;
    font-family: 'Roboto', sans-serif;
    font-size: 20px;
    font-weight: bold;
    align-self: center;
    margin: 0 5%;
    padding-top: 20px;
}

As demonstrated in the code above, with the borders of the inputs set to 4px, the original border that I cannot seem to get rid of appears above the custom borders. My goal is actually to have no borders at all, and I only included the border: 4px; example for illustrative purposes.

Answer №1

One way to eliminate the border from an input is by using border: none;.

If you also wish to remove the border when the input is in focus, you can add the following CSS rule:

input:focus{ border:none;outline:0; }

.min input, .sec input, .hour input{
border: none;
}
.min input:focus, .sec input:focus, .hour input:focus{
border: none;
outline:0;
}
h2 {
    margin-top: 20px;
    border-bottom: 2px solid #ccc;
    padding-bottom: 5px;
    text-align: left;
    color: gray;
    font-size: 16px;
    font-weight: normal;
    width: 131px;
}

.min, .sec, .hour {
    font-family: 'Roboto', sans-serif;
    width: 33px;
    box-sizing: border-box;
    border: none;
    font-size: 16px;
    margin: 0;
    padding: 0;
    background: white;
    display: inline-block;
}

h3{
    border-top: 2px solid #ccc;
    width: 131px;
}

.time-container {
    display: flex;
    width: 100%;
    align-self: center;
    justify-content: center;
}

.hyphen {
    color: #ccc;
    font-family: 'Roboto', sans-serif;
    font-size: 20px;
    font-weight: bold;
    align-self: center;
    margin: 0 5%;
    padding-top: 20px;
}
<div class="time-container" align="center">
    <div id="start" align="middle">

                    <h2 class="start-time">start</h2>

            <div class="time">
                    <form class="hour">
                        <input type="text" size="3" maxlength="3" placeholder="hr">
                    </form>
                    :
                    <form class="min">
                        <input type="text" size="3" maxlength="2" placeholder="min">
                    </form>
                    :
                    <form class="sec">
                        <input type="text" size="3" maxlength="2" placeholder="sec">
                    </form>
            </div>

                    <h3></h3>

    </div>



            <div class="hyphen">
                &#45;
            </div>



    <div id="stop" align="middle">

                    <h2 class="end-time">end</h2>

            <div class="time">
                    <form class="hour">
                        <input type="text" size="3" maxlength="3" placeholder="hr">
                    </form>
                    :
                    <form class="min">
                        <input type="text" size="3" maxlength="2" placeholder="min">
                    </form>
                    :
                    <form class="sec">
                        <input type="text" size="3" maxlength="2" placeholder="sec">
                    </form>
            </div>

                    <h3></h3>
    </div>
</div>

Answer №2

For your input fields, implement the following CSS properties: outline: none and border: 0.

input,
input:focus {
  outline:none;
  border: 0
}

h2 {
    margin-top: 20px;
    border-bottom: 2px solid #ccc;
    padding-bottom: 5px;
    text-align: left;
    color: gray;
    font-size: 16px;
    font-weight: normal;
    width: 131px;
}

.min, .sec, .hour {
    font-family: 'Roboto', sans-serif;
    width: 33px;
    box-sizing: border-box;
    border: none;
    font-size: 16px;
    margin: 0;
    padding: 0;
    background: white;
    display: inline-block;
}

h3{
    border-top: 2px solid #ccc;
    width: 131px;
}

.time-container {
    display: flex;
    width: 100%;
    align-self: center;
    justify-content: center;
}

.hyphen {
    color: #ccc;
    font-family: 'Roboto', sans-serif;
    font-size: 20px;
    font-weight: bold;
    align-self: center;
    margin: 0 5%;
    padding-top: 20px;
}
<div class="time-container" align="center">
    <div id="start" align="middle">

                    <h2 class="start-time">start</h2>

            <div class="time">
                    <form class="hour">
                        <input type="text" size="3" maxlength="3" placeholder="hr">
                    </form>
                    :
                    <form class="min">
                        <input type="text" size="3" maxlength="2" placeholder="min">
                    </form>
                    :
                    <form class="sec">
                        <input type="text" size="3" maxlength="2" placeholder="sec">
                    </form>
            </div>

                    <h3></h3>

    </div>



            <div class="hyphen">
                &#45;
            </div>



    <div id="stop" align="middle">

                    <h2 class="end-time">end</h2>

            <div class="time">
                    <form class="hour">
                        <input type="text" size="3" maxlength="3" placeholder="hr">
                    </form>
                    :
                    <form class="min">
                        <input type="text" size="3" maxlength="2" placeholder="min">
                    </form>
                    :
                    <form class="sec">
                        <input type="text" size="3" maxlength="2" placeholder="sec">
                    </form>
            </div>

                    <h3></h3>
    </div>
</div>

Answer №3

On occasion, there may be a box-shadow that impacts the layout even when the border is set to 0. However, I was able to resolve this issue by eliminating the box shadow.

/* The code below was removed */
 -webkit-box-shadow: inset 0 1px 2px rgba(10,10,10,.1); 
 box-shadow: inset 0 1px 2px rgba(10,10,10,.1);

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

Tips on positioning only one list item on your Bootstrap navbar to the right

I am currently learning to code with HTML and am attempting to create a navigation bar with some list items on the right side and some on the left. Although I'm using Bootstrap, I am unable to figure out how to move only the 'contact' item t ...

The relationship between formatting context and atomic inline-level boxes is crucial for understanding

Check out this link for more information on inline boxes An inline box is a unique element that falls under the category of both inline-level and participates in its containing inline formatting context. When a non-replaced element has a 'display&ap ...

Identical CSS styling, selectors, and images, but varying heights?

Encountering a strange issue in Safari and Chrome, but not in Firefox. To see the problem, check out this URL in either Safari or Chrome: Upon scrolling down, you'll notice a video thumbnail that behaves differently compared to the others. Specifica ...

Is it possible to prevent the fade out of the image when hovering over the text after hovering over the div or image, causing the text to fade in?

Using React and CSS. I have set up my application to display a faded image on hover, with text that fades in over it. However, I am facing an issue where touching the text with my cursor removes the fade effect. Does anyone have a solution for preventing ...

The visual glitch caused by a radial gradient on IOS is quite noticeable

https://i.sstatic.net/Q5U4u.png https://i.sstatic.net/miWXC.png The images depict a visual artifact created by the radial gradient, which I am utilizing as a mask to achieve an iOS-like effect. background:-webkit-radial-gradient(transparent 0%,transp ...

What is the process for eliminating the overflow in this situation?

How can I eliminate the overflow issue with this toggle button? The functionality of this toggle button is simple - you click on it to turn it on and off. I've been struggling to find a solution. Every attempt so far has been unsuccessful. All I wa ...

CSS animations for loading page content

Currently, I am incorporating animations into my project using HTML5 and CSS3, and the progress has been smooth. I have been able to achieve effects such as: #someDivId { position: absolute; background:rgba(255,0,0,0.75); transition: all 0.7s ...

Menu navigation - ensuring the background color extends to cover the entire page, not just the viewport

I'm facing an issue with the left navigation bar's design. Specifically, I'd like the grey color of the bar to extend vertically across the entire page. Currently, the gray bar ends at the viewport's edge. Is there a way to make the ba ...

Incorporating a read more section in WordPress with a div

I've been trying to implement a read more button with a div, but it doesn't seem to be working. I'm unsure of the correct approach to take. Below is the code I am using: <?php the_content('<a href="<?php the_permalink() ?> ...

What could be causing the javascript styling to malfunction when using Ractive.js?

When the button is clicked in this fiddle, it seems that in addition to other lines, the following code is also being executed: document.getElementById("WeatherData").style.visibility = "block"; weatherDataDiv.style.visibility='block'; However, ...

The inline-flex element is experiencing alignment issues

I have 3 elements (with yellow background) that display monetary amounts. Each counter is animated whenever the amount changes, so there is specific HTML/CSS code for each counter to handle the animation. Changing the underlying CSS will disrupt the anima ...

Customize the active text color of breadcrumbs in Bootstrap

My goal is to change the text color "About us" in the breadcrumb to black, but my attempts have been unsuccessful. <ol class="breadcrumb"> <li class="disabled"><a href="index.html">Home</a></li> <li class="active"& ...

Executing HTML and JavaScript code stored as a string

I want to display a string that includes HTML and JavaScript. It is important that the JavaScript is interpreted similarly to jQuery's $.load(), but without using jQuery. Here is an example of what I am attempting to achieve: https://jsfiddle.net/4tf ...

How can you deactivate all form elements in HTML except for the Submit button?

Is there a method available to automatically deactivate all form elements except the submit button as soon as the form loads? This would entail pre-loading data from the backend onto a JSP page while restricting user access for editing. Users will only be ...

connect the value of an input to the style of a different element

I'm struggling with the following code snippet <input id="in" value="50px"/> <div id="out">this is my output</div> Could anyone guide me on how to use jQuery to bind the #in value to the #out's font-size? Considerations: a ...

Length of borders at the bottom of `td` elements in tables

I have been searching everywhere for a solution and just can't seem to figure it out. I am trying to adjust the length of the bottom border for td elements within a table. I have attached two screenshots for reference. Any assistance would be greatly ...

I'm attempting to set up three columns that fade in responsively. Is there a way to make them appear side by side instead of stacking on top of each other?

Is there a way to display the three columns horizontally instead of vertically? I also want them to adjust responsively and fade smoothly. Here is my fiddle link: https://jsfiddle.net/Spleendrivel/dswufb78/3/ <!DOCTYPE html> <html> <head ...

Develop a stylish contact form using a mixture of HTML5, Bootstrap, and Php

On my website, I have created a contact us form using HTML, Bootstrap, and PHP. The form functions correctly, and messages are successfully received. However, the issue is that upon clicking the submit button, a new page opens up displaying a "Thank you me ...

Is it better to parse HTML using xpath or cssSelector?

Is there a way to extract only the text content from these code blocks using Selenium client drivers in Java? <li id="NOT_PUT_PREF_STORE" style=""> <span id="STORE_AVAIL" class="BodyLBoldGrey StockStat">Out of stock</span> <span id="I ...

Struggling to find a solution for altering font color with jQuery while creating a straightforward menu

I'm having trouble changing the color of the active button pressed to "color:white;"... Here is the link to the jsfiddle: http://jsfiddle.net/wLXBR/ Apologies for the clutter in the file, my css is located at the bottom of the CSS box (Foundation cod ...