div element's default input border displays in a distinct manner

When I create an input box without any styles (<input>) and then inspect the computed CSS in devtools, it shows a border of 2px inset rgb(238, 238, 238).

However, if I create a div with the same border properties, it looks noticeably different:

<input>
<br><br>
<div style="border: 2px inset rgb(238, 238, 238); height:15px; width: 169px; "></div>

Why is that? And what type of border should I use to achieve the same appearance as the input?

Answer №1

Is this the desired format?

<input>
<br><br>
<div style="border: 1px solid rgba(0, 0, 0, 0.4); height:15px; width: 169px; "></div>

Answer №2

The border size is 2 pixels, which is revealed when the background of the input is changed to #f1f1f1. Take a look at the example below:

<input style="background:#f1f1f1;">
<br><br>
<div style="border: 2px inset rgb(238, 238, 238); height:15px; width: 169px; "></div>

Answer №3

Similar to the <input> style you are using

border: 1px solid rgba(0,0,0,0.4);
height: 19px;
width: 171px;

inset - Specifies a border with a 3D inset effect.

solid - Indicates a solid border arrangement.

This is the primary distinction in your styling approach.

Answer №4

Found it!

The input has the style -webkit-appearance:textfield; applied to it.

div {
  border: 2px inset;
  -webkit-appearance: textfield;
  height: 15px;
  width: 169px;
}
<input>
<br><br>
<div></div>

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

Confirm that the CSS syntax is valid

Is there a way to validate CSS syntax by checking for specific characters like "{", "}", ";", and ":"? I have come up with four checks to ensure the code is valid, such as verifying that the number of opening and closing curly braces match, as well as the ...

``There is a misalignment issue in the CSS Flip Animation that needs to be fixed

I am currently working on implementing a CSS flip animation that I found here into my website. The animation itself is functioning properly, but I am facing an issue with aligning the text I want to include in the center of both the front and back sides. W ...

Web Page Layout Altered on Smaller Screen with Internet Explorer 6

After designing an ASP.NET web page on a widescreen monitor with IE10, I was surprised to see it looking completely different when opened on a regular (non-widescreen) monitor running IE6. While the functionality remained intact, some transparency effect ...

What is the best method to retrieve particular HTML lines (containing a flex container) with IronPython?

Utilizing IronPython 2.7.9.0 in Grasshopper and Rhino, I am extracting data through web scraping from a specific widget on the following link: The code snippet being used is shown below import urllib import os web = urllib.urlopen(url) html = web.read() ...

When a user accesses a page, the UI-router shows the raw code in the UI-views

I am a newcomer to utilizing ui-router and I am facing challenges with managing routing and reloading some states. Any assistance would be greatly appreciated. An overview of my index.html <html ng-app="resApp"> <head></head> < ...

Step-by-step guide on displaying a window containing text when hovering over a CSS class

As a beginner in css, html, and js, I created an html page with a table of athletes. Each row is identified by the css class "athlete-name", like this: <div id="message-hide" style="display: none"> Hello world! </div> <t ...

NiceScroll is failing to show up after an Ajax reload

I've been searching everywhere for a solution to my problem. The issue I'm facing with the AJAX load and nicescroll plugin is a bit unique compared to what I've found so far. The problem is that Nicescroll isn't functioning on a separat ...

Tips for hiding website content on larger screens

Is there a way to hide website content on screen sizes over 1600px and display only a message image instead? ...

unusual behavior observed in addEventListener

I have recently delved into learning about the DOM. I have a project in mind where I want to create a website with buttons that, when clicked, play different drum sounds. As part of my experimentation with JavaScript, I wanted to explore the this keyword. ...

The offset values of $(element) keep increasing indefinitely when they are updated repeatedly

After researching how to utilize JavaScript drag functionality to move elements, the goal is to dynamically adjust the cursor position within a square when dragged. In an attempt to simplify the process and avoid storing x and y offsets as separate variabl ...

Is it possible to apply identical css styles to multiple ids at once?

Is there a way to accomplish this? .apple, .orange, .kiwi h1 {color: #892828;} I'm having trouble making it work. Any suggestions? ...

Update the HTML table by changing the first cell in the first row to span multiple

I currently have a table structured like this: <table> <thead> <tr> <th></th> <th>Col1</th> <th>Col2</th> <th>Col3</th> <th>Col4& ...

Boost the dimensions of the content property within a CSS class

I am currently using the content property to display a dashed arrow "-->" in my CSS class. However, the arrow appears very small and I would like to increase its size directly in the CSS class itself. This arrow is meant to be displayed before each elem ...

Changing the content of a <div> element using the information retrieved from the previous page

When the user clicks the "Edit" button, I am redirecting them from another page using the following code snippet. $('#editListButton').click(function(){ window.location.href = "http://localhost/yyy.php"; //redirect // Modifications th ...

Guide on using a while-loop in selenium with python to continuously run until a specific element is no longer present on the page

I'm currently facing a challenge with creating a while-loop that will run until a specific element is no longer present on a website. My existing solution gets the job done, but I know there's room for improvement. I would love to hear suggestion ...

Center content within a div using the middle alignment

Here's a question that goes beyond your typical "vertical align center" query. What I want to accomplish is to take a div with an unspecified height and position it at a specific percentage down the page, let's say 33%. I have managed to get this ...

Update the iframe located on a different webpage

I am looking to create a dynamic button feature on my website where clicking a button on page1.html will open a new page (portal.html) with an iframe displaying the URL specified in the button. The setup involves two main pages: page1.html, and portal.htm ...

Is there a Firefox extension for optimizing absolute CSS positioning for faster web development?

When it comes to working with CSS, I prefer using Firebug and adjusting the top and left values with the up and down arrow keys. Has anyone found a Firefox add-on that allows me to drag elements around and then easily copy and paste the top and left value ...

What is the best way to implement target="_blank" in an anchor tag using 'sanitize-html'?

In my current project, I am utilizing the sanitize-html library. Let's say I receive an email containing an anchor tag like this: this is to test something <a href="https://www.google.com/">open google</a> When this email shows up in my ...

Anchoring links on a webpage that provide users with a clear indication of their current position within the page

In the scenario of a single-page website with various sections (divs) and a header containing links to different anchors on the page, there is a desire to have an indicator highlight which anchor the user is currently viewing. An example of this can be s ...