The content following customized checkboxes does not align with the baseline

Here is the code snippet:

<p><input type="checkbox" /> Pavement
<input type="checkbox" /> Dirt or rocky trails
<input type="checkbox"/> Gravel roads</p>

As well as the accompanying CSS:

h1, input, button, textarea, progress, p, a, ul, li {
    font-family: "Open Sans", sans-serif;
    font-size: 10pt;
    color: #666;
    letter-spacing: normal;
    text-indent: 0;
    text-shadow: 0 1px 0 hsla(0,0%,100%,.75);
    margin: 10px 2px;
}

input[type="checkbox"], input[type="radio"] {
    background-color: #f4f4f4;
    background-image: -webkit-linear-gradient(90deg, hsla(0,0%,0%,.05), hsla(0,0%,0%,.01));
    box-shadow: inset 0 1px 0 hsla(0,0%,100%,.5),
                0 1px 2px hsla(0,0%,0%,0.5);
    border: none;
    cursor: pointer;
    height: 16px;
    width: 16px;
    position: relative;
    -webkit-appearance: none;
}

The checkboxes appear to be very close together in relation to the surrounding text. Removing all of the CSS seemed to fix the issue, but once I started removing/replacing individual lines of CSS, I couldn't pinpoint the problem. Any suggestions on what may be causing this? Thank you!

Answer №1

Here's the issue you're facing:

margin: 10px 2px;

Simply remove it and everything will work smoothly

Alternatively, if you wish to retain it for certain elements but not for checkboxes and radio buttons, you can try this approach

h1, input, button, textarea, progress, p, a, ul, li {
  ...
  margin: 10px 2px;
}
input[type="checkbox"], input[type="radio"] {
  ...
  margin: 0px 2px;
}​

Answer №2

Make sure to include the rule vertical-align: middle; for your checkboxes to properly align.

For example:

input[type="checkbox"], input[type="radio"] {
...
   vertical-align: middle;
}

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

How can I create a customized placeholder effect for the Paytm login page text box?

Looking to create a placeholder effect on the text boxes for a Paytm login page? https://i.sstatic.net/sox0a.png ...

Styling DL and DD elements with Zend Framework decorators

When incorporating a Subform named "Step1," your code will look like this: <dl class="zend_form"> <dt id="Step1-label"></dt> <dd id="Step1-element"> <fieldset id="fieldset-Step1" class="Step"> < ...

Is it possible to verify if a bearer token has expired within an Angular application?

Is there a secure and efficient way to determine when a bearer token has expired in my Angular application? This is the issue I am facing: If I keep the app open in my browser, someone could potentially access sensitive information on my screen since I am ...

Injecting AngularJS directives and styling elements into the body section of a Twig template using the {% block body %} tag

I'm currently in the process of constructing a Rest API using Symfony 3 and Fosresbundle, with AngularJS responsible for fetching JSON data within twig templates. However, I've encountered an issue where I need to specify angularJS directives an ...

Developing a form using ASP.NET with dual models

I am currently using Visual Studio 2017 with all the latest updates installed. I am facing a challenge where I need to create a form with text box answer questions and a checkbox answer question, and then store all the answers in a single database entry. M ...

When XML is accessed through an iframe, it is interpreted as HTML

In my endeavor to display an xml file within an HTML page using an iframe and altering the content through jQuery by manipulating the source attribute, I encountered a curious issue. When I viewed the xml file directly in my browser (Firefox/Chrome/IE8), i ...

I am looking to create an engaging photo viewing experience by utilizing a modal to display each image in my gallery when clicked

I created a stunning image gallery featuring 13 photos that I discovered on W3Schools and customized to suit my own preferences. The gallery looks great, but there's an issue - only the first image can be opened using a modal window. I tried editing s ...

Ways to capture all characters (including special characters like ) using Visual Studio Regex

What I'm Hoping to Achieve: I am looking to reformat multiple HTML files that have a similar structure in Visual Studio. While the HTML sections may vary in length, they all begin with a <div id="some_id"> tag and do not contain any other <d ...

Aligning the title vertically in Ionic on Android device

Currently, I am in the process of developing an application using the Ionic framework and cordova. After uploading my app for testing purposes, I encountered a small issue. The title in the top bar on Android appears to be misaligned vertically. Is there a ...

Unable to choose the option from the modal that functions similarly to a drop-down menu

I need to choose a field that functions similarly to a dropdown box, but does not actually display as one. The select field reveals its values in a pop-up with values and sub-values that I need to select. Challenges : I'm struggling to locate the ob ...

How can I enable the "Open in a new tab" functionality while utilizing ng-click?

I've encountered an issue with my HTML table where each row is supposed to link to a different page, providing more detailed information. However, because I am using angularjs and utilizing ng-click on the rows, I am unable to right-click and select & ...

What circumstances could lead to Chrome's autofill feature ceasing to function?

Currently, we are in the process of developing a new website that utilizes HTML5. While everything validates correctly, we are encountering issues with the LESS stylesheets and Facebook tags. Particularly, Chrome's autofill feature is not functioning ...

What are some effective replacements for SoundManager2 worth considering?

While Soundmanager2 is a useful app, many find the code to be overly complex and difficult to navigate. It almost seems as if it was purposely written in a way to confuse rather than clarify. Are there any recommended alternatives to Soundmanager2 that are ...

Table within a table does not occupy full height within a table cell

I encountered an issue while nesting a table within a td element. The behavior differs between browsers: in Firefox, the nested table fills the entire cell from top to bottom, but in Edge and Chrome, it is centered within the td cell and does not occupy th ...

Experience the magic of a customized cursor that disappears with a simple mouse movement in your website,

I have been experimenting with designing a custom cursor for my website. After finding a design I liked, I made some adjustments to suit my needs. However, an issue I encountered is that when I scroll, the custom cursor also moves away from its original po ...

Sticky header in an Angular Material table

Using Angular 7 with Angular material design templates, my current result looks like this: https://i.sstatic.net/G4W78.jpg However, I am aiming for a result similar to the following - with a scrollbar under the sticky header. https://i.sstatic.net/WgjVh ...

Switching the angularjs variable from html; a definitive guide

How can I update a variable in an AngularJS controller using JavaScript when a specific HTML element is clicked? For instance: angular.module('app',[]) .controller('appController', function($scope, $http){ $scope.on ...

Align the footer vertically with Bootstrap 4, ensuring it stays in line with columns and rows

Seeking a solution to vertically align the 2 rows within the footer, both arranged using a Bootstrap grid. My attempt involved creating a content wrapper and utilizing a conventional flexbox solution: display: flex; align-items: center. However, this caus ...

jQuery Modal activated only once upon clicking

Recently, I've been experiencing a frustrating issue that's giving me a splitting headache. Despite scouring this forum for answers, my problem persists. Here's the situation: I have a button that triggers modals. Upon first click after refr ...

What adjustments can be made to alter the height of the borders on the left and right side of the block quote, and link the border to a different div element

Block Quote Example I'm looking to create a blockquote that resembles the image provided. I have successfully implemented the top and bottom gradients, but am facing challenges with the left and right borders as well as rounding the quotations more. ...