What could be causing this element to not float left in Firefox?

Can anyone help with aligning a checkbox to float left in Firefox? I can't seem to figure out what's causing the issue.

Example that demonstrates the issue: http://jsfiddle.net/3zhrD/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <title>Sample</title>
        <style type="text/css">
body {
    font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
    font-size:12px;
}
p, h1, form, button {
    border:0;
    margin:0;
    padding:0;
}
.spacer {
    clear:both;
    height:1px;
}
/* ----------- My Form ----------- */
.myform {
    margin:0 auto;
    width:400px;
    padding:14px;
}
/* ----------- stylized ----------- */
#stylized {
    border:solid 2px #b7ddf2;
    background:#ebf4fb;
}
#stylized h1 {
    font-size:14px;
    font-weight:bold;
    margin-bottom:8px;
}
#stylized p {
    font-size:11px;
    color:#666666;
    margin-bottom:20px;
    border-bottom:solid 1px #b7ddf2;
    padding-bottom:10px;
}
#stylized label {
    display:block;
    font-weight:bold;
    text-align:right;
    width:140px;
    float:left;
}
#stylized .small {
    color:#666666;
    display:block;
    font-size:11px;
    font-weight:normal;
    text-align:right;
    width:140px;
}
#stylized input { /*260*/
    float:left;
    font-size:12px;
    padding:4px 2px;
    border:solid 1px #aacfe4;
    width:200px;
    margin:2px 10px 2px 10px;
}
#stylized .checkbox {
    margin:2px 10px 28px 10px;

}
#stylized button {
    clear:both;
    margin-left:150px;
    width:125px;
    height:31px;
    background:#666666 url(img/button.png) no-repeat;
    text-align:center;
    line-height:31px;
    color:#FFFFFF;
    font-size:11px;
    font-weight:bold;
}
</style>
        <script type="text/javascript">
            function CredentialsReadonlyToggle() {
                if(document.getElementById("CredToggle").checked){
                    document.getElementById("username").disabled=true;
                    document.getElementById("password").disabled=true;
                }
                else
                {
                    document.getElementById("username").disabled=false;
                    document.getElementById("password").disabled=false;
                }
            }
        </script>
        </head>
        <body>
        <div id="stylized" class="myform">
          <form id="form" name="form" method="post" action="index.html">
            <h1>Choose Source</h1>
            <p>This is how my form looks without using a table layout</p>

            <label>URL <span class="small">URL of Remote Address</span> </label>
            <input type="text" name="url" id="url" />

            <label>Require Password? <span class="small">Source requires password</span> </label>
            <input type="checkbox" onclick="CredentialsReadonlyToggle();" id="CredToggle" class="checkbox"/>

            <label>Username <span class="small">for remote source</span> </label>
            <input type="text" name="username" id="username"/>

            <label>Password <span class="small">for remote source</span> </label>
            <input type="password" name="password" id="password"/>
            <button type="submit">Next</button>
            <div class="spacer"></div>
          </form>
        </div>

</body>
</html>​

In response to the suggestion from G-Nugget, I made some changes in the CSS and enclosed the checkbox in a div, but unfortunately, it didn't resolve the issue.

#stylized .checkbox {
    float: left;
    margin-left: 0px;
}
#stylized div{
    margin:2px 10px 28px 10px;
    float:left;
    border:solid 1px #000;
    }

Answer №1

Hello, please update the CSS for the label and checkbox as shown below. The width of the checkbox needs to be reset since the input already has a width of 200px. I made changes to the jsfiddle and tested it on both Firefox 18 and Safari.

#custom label {
display:block;
font-weight:bold;
text-align:right;
width:130px;
clear:left;
float:left; }

#custom .checkbox {
margin:2px 10px 28px 10px;
width:20px;}

Answer №2

After updating the doctype to html5, I was pleased to see the expected results.

It's generally recommended to avoid transitional doctypes as they can put your page in quirks mode, unless there is a specific and compelling reason to use one.

Answer №3

To enhance the design, include the following code: #stylish label {float:none;}

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

Are you attempting to retrieve the most up-to-date trading price of a stock with Python?

After attempting to extract the LTP of a stock with the code below, I am not getting any value in return. Can you identify the error in the following code: from selenium import webdriver from bs4 import BeautifulSoup driver=webdriver.Chrome("C:&bsol ...

Using Angular to condense or manipulate an array

I am working with a JSON response that contains arrays of arrays of objects. My goal is to flatten it in an Angular way so I can display it in a Material Table. Specifically, I want to flatten the accessID and desc into a flat array like [ADPRATE, QUOCON, ...

Creating fixed position scroll triggered animations in React is a simple process that adds dynamic motion to your

In my project, I am aiming to create an animation that is triggered by a fixed position as demonstrated in the following example. I am currently utilizing React, Typescript, and Tailwind, while also experimenting with animation libraries such as Framer Mot ...

When using the Column width property in React Material UI, it may not automatically expand

I've been playing around with React Material UI Tables and I'm having trouble making the columns auto-expand without wrapping. I tried setting the 'width: auto' property in the <Table size="small" style={{ width: auto}}> ...

An assessment consisting of three parts, with the initial section required to match the size of the browser window using jQuery and Javascript

UPDATE: The issue was resolved by adding the Doctype at the top of the page - "<!DOCTYPE html>" (no spaces between tags < , > and other characters) I am experimenting with a webpage that contains four sections. The first section should take up ...

What are some techniques for styling a field when the div id is not specified?

I need to customize a data field within a table, but I am unable to locate or identify its div ID. Here is the page source: <tbody> <tr> <td style="font-size:12px; text-align:center;" name=""> <div sty ...

What is the best way to present the new segment?

Having trouble with creating new sections or content after the homepage? The issue is that the new content doesn't appear on a new page but rather on the homepage itself. An example of this problem can be seen on this CodePen project, where an h1 sect ...

Animate the removal of a div message with the help of CSS and jQuery

To display a success message in PHP, I use the following code snippet: <div class='alert alert-success'>Success!!</div> In addition to that, I have implemented a CSS3 animation called Animate: .animated { -webkit-animation-durati ...

Utilizing BeautifulSoup for Web Scraping (handling missing values during the scrape)

I have been facing two challenges while trying to scrape data from a realtor website using BeautifulSoup. These issues have proven to be quite tricky: Challenges: After running my code snippet, I noticed that some date values are missing in the dataframe ...

Utilizing JavaScript to dynamically update the user interface after submitting a form using jQuery

I am working on implementing an Input element that triggers a form submission: <input type="submit" value="Download" id="downloadButton" class="btn-download" /> The specific requirement is for the button to first execute a javascript function and t ...

Retrieve the count of ng-if directives that match a specific ng-repeat content

Imagine a scenario where HTML code looks like this: <md-grid-tile class="gray" ng-repeat="carto in cartoList" ng-if="search(carto)"> <md-button ng-click="changeSVG(carto.fileName)" aria-label="carto.displayName"> <img ...

Streamline your CSS selectors that share a common parent for more efficiency

.content p, .content ul, .content h1 { text-indent: 35px; } Is there a more concise way to write this selector, such as .content p, ul, h1 {}?                                                      ...

Removing the background inside an Iframe using HTML

Is there a method to eliminate the background color from the original site within an Iframe? It currently displays as white. Would it be possible to achieve this with Javascript? ...

What is the best way to include a .wav file within a PHP if statement?

I am new to PHP and coding in general, so please bear with me if I sound inexperienced. I am attempting to play a WAV file from a PHP if statement. However, when I try to echo the HTML for the sound, I encounter this error: PHP Parse error: syntax error, ...

Manipulating child elements in XML, JavaScript, and jQuery – the possibilities are endless!

I have a good grasp on how to extract elements and write them to a document in JavaScript using the HttpXMLRequest object. However, I am struggling to find resources that explain how to modify it further. I believe part of the issue is that I am unsure of ...

Text area featuring unique border design, with border color change upon focus?

Currently, I have a text area with borders that are designed in a unique way. However, I am looking to change the border color when the user focuses on the text area. Do you have any suggestions on how I can achieve this effect without affecting the curre ...

HTML directory selector

As a beginner in HTML, I have a file available for users to download: <a href="filetodownload.exe" download>Download</a> By default, the file is downloaded to the Downloads directory. Is there a way to prompt the user with a dialog b ...

"Looking to add some flair to your website with a

I am trying to figure out how to place a 30x30px no-repeat background image in the top left corner of a 200px by 200px div, positioned 120px from the left and 50px from the top. However, I also want to ensure that the text inside the div is displayed on to ...

What is the procedure for submitting all checkbox values through Google Apps Script?

My web app created using Google Apps Script can generate a custom table of data for users to select for calculations. I use Google Sheets to populate the table with values and checkboxes, but note that the table size may vary depending on the user. <fo ...

Remove Bootstrap-Table's box-shadow on the search bar's delete button

Is there a way to eliminate the box-shadow from the search box upon clicking on it? I am familiar with removing box-shadows from classes in CSS, but I am unsure of how to remove the box-shadow from a specific property like "data-search" within the tag. ...