The button within a form expands in length when using HTML5 format

Everything seems fine, but in HTML5 mode, the search button may look longer than expected. I am using Chrome 56 on Windows 10.

I'm having trouble figuring out why this is happening.

Original code:

body {
    font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
    font-size:14px;}
 
h1 {
    margin-top:0px;
    margin-bottom:8px;
}
 
/* Links */
a {
    text-decoration:none;
    color:#1c00ff;
}
 
a:hover {
    color:#5f00e4;
}
fieldset.search {
    padding: 0px;
    border: none;
    width: 232px;
    background:#e0e0e0;
}
 
<fieldset.search:hover {
    background: #a8a8a8;
}
.search input, .search button {
    border: none;
    float: left;
}
.search input.box {
    height: 28px;
    width: 200px;
    margin-right: 0px;
    padding-right: 0px;
    background: #e0e0e0;
    margin: 1px;
}
.search input.box:focus {
    background: #e8e8e8 ;
    outline: none;
}
.search button.btn {
    border: none;
    width: 28px;
    height: 28px;
    margin: 0px;
    padding: 0px;
    background: url(http://sandbox.runjs.cn/uploads/rs/339/livk7pl5/search_blue.png) no-repeat top right;
}
.search button.btn:hover {
    background: url(http://sandbox.runjs.cn/uploads/rs/339/livk7pl5/search_black.png) no-repeat bottom right;
}
 
/* Article styles */
.article {
 
}
<html>
  
<head>
<title>Implement Search Bar</title>
<meta charset="UTF-8">

</head>
<body>
<div>
<h2>Search Bar</h2>
<form method="get" id="searchform" action="http://blog.iliyang.cn/">
    <fieldset class="search">
         <input type="text" class="box" name="s" id="s" class="inputText" placeholder="Valentine’s Day" x-webkit-speech>
          <button class="btn" title="SEARCH"> </button>
    </fieldset>
</form>
</div>
<article class="article">
</article>
</body>
</html>

The imagehttps://i.sstatic.net/zFUcw.png

Here is my updated code with the first line changed to HTML5:

body {
    font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
    font-size:14px;}
 
h1 {
    margin-top:0px;
    margin-bottom:8px;
}
 
/* Links */
a {
    text-decoration:none;
    color:#1c00ff;
}
 
a:hover {
    color:#5f00e4;
}
fieldset.search {
    padding: 0px;
    border: none;
    width: 232px;
    background:#e0e0e0;
}
 
fieldset.search:hover {
    background: #a8a8a8;
}
.search input, .search button {
    border: none;
    float: left;
}
.search input.box {
    height: 28px;
    width: 200px;
    margin-right: 0px;
    padding-right: 0px;
    background: #e0e0e0;
    margin: 1px;
}
.search input.box:focus {
    background: #e8e8e8 ;
    outline: none;
}
.search button.btn {
    border: none;
    width: 28px;
    height: 28px;
    margin: 0px;
    padding: 0px;
    background: url(http://sandbox.runjs.cn/uploads/rs/339/livk7pl5/search_blue.png) no-repeat top right;
}
.search button.btn:hover {
    background: url(http://sandbox.runjs.cn/uploads/rs/339/livk7pl5/search_black.png) no-repeat bottom right;
}
 
/* Article styles */
.article {
 
}
<!DOCTYPE html>
  
<head>
<title>Implement Search Bar</title>
<meta charset="UTF-8">

</head>
<body>
<div>
<h2>Search Bar</h2>
<form method="get" id="searchform" action="http://blog.iliyang.cn/">
    <fieldset class="search">
         <input type="text" class="box" name="s" id="s" class="inputText" placeholder="Valentine’s Day" x-webkit-speech>
          <button class="btn" title="SEARCH"> </button>
    </fieldset>
</form>
</div>
<article class="article">
</article>
</body>
</html>

The image https://i.sstatic.net/YoClg.png

If anyone can offer assistance, it would be greatly appreciated.

Answer №1

It seems the "px" is missing in your CSS rule

.search input.box {width: 200px;}

However, I'm not sure if this will fix the issue as both fields appear identical to me.

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

Guide on showcasing specific columns from a table by utilizing an HTML listbox in conjunction with SQL coding

Hello, I need assistance with a specific task. I am looking to create a table that has two columns: one for the Country and one for the Capital. This table should list every country in the world along with its corresponding capital. Additionally, I would l ...

Having difficulty aligning the button in the center

I encountered an issue trying to center a button, I attempted to use text-align: center, but it didn't have the desired effect. .regis-btn { border-radius: 0px; text-align: center; -moz-border-radius: 10px; -webkit-border-radius: 10px; -o ...

Steps to align an SVG to the right within a div

I'm struggling to get an SVG to align at the end of its containing div. The div is set to display in flex and I've tried using "align-self: flex-end" on the a tag that wraps the svg, as well as experimenting with block and float-right. Any sugges ...

scroll smoothly to a specified vertical position on a webpage using jquery animation

Hello everyone, I am relatively new to JS and currently working on creating a vertical image scroller. I have successfully implemented code to scroll from left to right on LI elements until the center of that LI is reached. However, I now want to apply thi ...

Button dropdown in Bootstrap not positioned below the button

I am struggling with the placement of a bootstrap button dropdown. Instead of appearing below the button, it is currently showing up underneath another div. Despite spending several hours on this issue, I have not been able to resolve it. HTML <!D ...

Trigger an alert when a button is clicked and redirect the user to an newly opened tab

I recently created a button with a link that opens in a new tab. I also implemented some JavaScript to display an alert. Everything is working as expected, but after the user clicks "OK" on the alert, they remain on the same page. I would like to automati ...

Navigate to element based on data attributes

Trying to find a way to scroll an element to a specific ID using data-attributes instead of anchor tags. Here is what I have so far: When a button is clicked, it should display the content and scroll to the element that matches the data-attributes. Howeve ...

Bringing in LESS variables to Rails 3

In my assets folder, I have a global.less file where I have defined various site-wide variables. Currently, in order to use these variables in other less files, I have to add this line at the beginning of each file: @import 'global'; While thi ...

Dynamically inserting a new row into a table with the power of jQuery

Currently working on dynamically adding rows to a table through jQuery in my project that follows MVC design pattern. I have set up a loop for the added rows, but need help with the script. Here is my code snippet for the loop : <?php $viewTableR ...

Executing a single query in PHP using multiple WHILE loops

Recently, I've been working on a PHP page that interacts with an Oracle Database through SQL queries. SELECT * FROM TABLE1; My challenge now is to run five WHILE statements based on the value of the recordset. Ideally, it would look something like t ...

Issue with triggering the change event for <select> tag

Whenever the selected value of the drop down changes, the following code does not work as expected. Please make corrections if any errors are present. <!doctype html> <html lang="en"> <head> <meta charset="utf-8</scri ...

JavaScript - The left dropdown menu stubbornly remains visible when clicked in white space, unlike the right dropdown which disappears as expected. Puzzled by this inconsistency

Whenever I click on the selection criteria box, a dropdown menu appears. Clicking on the white space or the data table button makes the drop-down menu disappear, which is good. However, when I perform the same action for 'choose data table,' the ...

having trouble with changing the button's background color via toggle

I've been experimenting with toggling the background color of a button, similar to how changing the margin works. For some reason, the margin toggles correctly but the button's color doesn't. <script> let myBtn = document.querySele ...

A bar is seen above the directive within the partial

My goal is to design a user interface using Angular on the front end. I have a directive called navbar. Despite using ngRoute, I incorporated this directive in my partial for /home. Everything seems to be functioning properly, but the navbar doesn't a ...

Problem: NgFor is failing to render the data

Hey there! I'm working on a project that involves Spring Boot, SQL, and Angular. I have set up one-to-many relationships, but I'm struggling to display the second object in my component's HTML. Here's my current setup: @Component({ se ...

Dynamic CSS Changes in AngularJS Animations

I am currently working on a multi-stage web form using AngularJS. You can see an example of this form in action by visiting the link below: http://codepen.io/kwakwak/full/kvEig When clicking the "Next" button, the form slides to the right smoothly. Howev ...

Transform inline styles in React to CSS declarations

Is there a tool available that can convert React inline style descriptions into CSS rules? For example: { minHeight: 200, position: 'relative', flexGrow: 1, flexShrink: 1, display: 'flex', flexDirection: ' ...

Displaying Angular JS 1.5 component's HTML content in the browser as a commented-out section

Exploring the Angular world and facing a challenging issue with a basic angular component. My goal is to incorporate a custom element called "cast-tile" on the page, loaded by angular as a component. However, the browser seems to be treating the code in n ...

I encountered an issue with my shopping cart while using ReactJS

this is the App.js file import React from "react"; import ListProduct from "./listProduct"; import ListOrder from "./listOrder"; import pizza from "./pizza.jpg"; import './style.css' import { Container,Row,Col,Button } from 'react-boo ...

Tips for maintaining the fixed size of a table header and preventing it from resizing in width

My goal was to create a table using divs with fixed headers while scrolling vertically. However, I encountered an issue where the header width seemed to shrink and became misaligned with the rows. Even setting the width to 100% did not resolve this probl ...