Tips for enhancing the appearance and functionality of an HTML form

Seeking advice on enhancing the styling of an HTML form I am developing for a course project. I'm particularly struggling to align the descriptors of radio buttons with their respective buttons. Any suggestions or guidance would be highly valued!

I have limited experience with HTML so I apologize in advance for any errors in the code.

Click here to view the current appearance of my radio buttons

HTML:

<h1> CONTACT FORM </h1>

<body>
    <div class="container">
      <form action="#" method="POST" class="form">
        <label for="name">FULL NAME</label>
        <input type="text" id="name" name="fullName" placeholder="Name" required />

        <label for="email">EMAIL ADDRESS</label>
        <input type="email" id="email" name="email address" placeholder="Email" required />

        <label for="phone">PHONE NUMBER</label>
        <input type="tel" id="tel" name="phone" placeholder="e.g. 012-345-6789" required />
        
         <label for="email">HOME ADDRESS</label>
        <input type="text" id="address" name="address" placeholder="Address" required />
        
        <label for="message"> MESSAGE</label>
        <textarea name="message" placeholder="Message" id="message" cols="40" rows="10"> </textarea>

         
       
        <p class="contact_method"> PREFERRED METHOD OF CONTACT </p>
        
        
         <div class="buttonradio">
      <input type="radio" id="html" name="best_contact" value="HTML">
<label for="Phone">Phone</label><br>
<input type="radio" id="Email" name="best_contact" value="Email">
<label for="email">Email</label><br>
<input type="radio" id="text" name="best_contact" value="Text">
<label for="text">Text message</label>
        </div>
        
        
        <button type="submit">SUBMIT</button>
      </form>
    </div>
  

CSS:

h1 {
  display: flex;
  font-family: 'Frank Ruhl Libre', serif;
  padding: 20px;
}

.container * {
  box-sizing: border-box;
    font-family: 'Frank Ruhl Libre', serif;
}
  
  
.form label {
  display: block;
  padding: 10px 0 5px 0;
  font-size: 15px;
    font-family: 'Frank Ruhl Libre', serif;
  font-weight: bold;
}

.form input,
.form textarea {
  font-size: 12px;
  display:flex;
  width: 50%;
  padding: 15px;
  background-color: #ffffff;
  border: none;
  border: 2px solid #000000;
  outline: none;
   border-radius: 10px;
  color: #000000;
}


.form input:focus:required:invalid {
  border-color: #000000;
  background-color: #fff;
}
/*   */


.form button {
  display: block;
  margin-top: 12px;
  width: 50%;
  padding: 12px 20px;
  border-radius: 10px;
    border-color: #000000;
  background-color: #000000;
  color: #fff;
  font-weight: 500;
  font-size: 13px;
  font-family: 'Frank Ruhl Libre', serif;
}

/* send button styling */




button:hover {
  background-color: chartreuse;
  transition: background-color 2s; 
  /* change color on hover */
  
}
  
.buttonradio {
  font-family: 'Frank Ruhl Libre', serif;
}
  
  .buttonst input{
   
    vertical-align: middle;
}


.contact_method {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 15px;
  padding-left: 12px;
  padding-top: 10px;
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: bold;
}



.container label {
    padding:5px;
    color:#222;
    font-size: 14px;
    margin: 10px;
}

input[type="radio"] {
  margin-top: -1px;
  vertical-align: middle;
  height: 100%;
}

Answer №1

Consider grouping the label and radio inputs together within a div or other container element, then use flex display properties to align items centrally within the wrapper for a cleaner layout.

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

Enhancing Choices with Attributes in Joomla

I'm attempting to include additional HTML attributes to certain select options within a dropdown list in Joomla 2.5, and I prefer to utilize the included HTML helpers rather than manually writing the HTML. The current display is as follows: <selec ...

Using a nested table will override the "table-layout: fixed" property

I'm currently working on creating a tabular layout and I'm in need of the following: 2 columns with variable widths Columns that are equal in width Columns that are only as wide as necessary After some research, I discovered that by setting "t ...

Exploring an unusual HTML structure using Python's Beautiful Soup and urllib for web scraping

While extracting data may not be a challenge, the real issue lies in locating it. My focus is on scraping football data from a website that presents statistics either for all years or for specific seasons. However, despite selecting a particular season, ...

Is it possible to eliminate the table borders and incorporate different colors for every other row?

Eliminating the table borders and applying color to alternate rows. Check out my code snippet: https://stackblitz.com/angular/dnbermjydavk?file=app%2Ftable-overview-example.ts. ...

What considerations should I keep in mind when changing the DOCTYPE from html 4.01 transitional to 'html'?

Firefox is telling me that my pages are being rendered in 'standards compliance mode' based on the doctype... <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> After changing it to < ...

Using jQuery, prevent the user from entering text into an input box when a checkbox

In my project, there is a checkbox that determines whether an input box is disabled. The issue arises when I try to disable the input based on the database value. For example, when the value is 0, it should display as disabled false; however, the input rem ...

Unusual vertical column in a container using bootstrap 4

Recently, I have been integrating simple Bootstrap 4 HTML pages into a WordPress project. I've utilized the container class for the containing divs. The pages function well overall, except for an unexpected vertical line that spans the entire pa ...

What could be causing the right padding to be overlooked next to the scroll bar, and what steps can be taken to address this

https://i.sstatic.net/0laRo.jpg .outer { padding: 50px; } .inner { width: 500px; height: 1000px; border: 1px solid gray; margin: auto; } <div class="outer"> <div class="inner"> <div class="content">qwerty</div> ...

Styling pagination for jquery dataTable

I've been looking into how to modify the pagination design, but haven't had much luck finding information on it. Currently, the table displays the standard default pagination style with the following jquery code. $('#id_view_student_table&a ...

Finding a specific child element using WebDriver

After encountering a particular issue with my HTML code structure, I found myself in a bit of a conundrum. The HTML consists of multiple divs, each containing the same set of tags but with different text within the h3 tag. My goal was to locate and interac ...

Is there a way to clear out all items from the cart using PHP?

I have a shopping cart with items that I want to remove all at once. I tried creating a submit button with the post method called 'remove_all', but it's not working and showing an error message saying "The requested URL was not found on this ...

Eliminate excess space around images in Bootstrap

I have an image tag with a padding applied to it. I am using the Bootstrap CSS framework. Currently, there is a white background behind the image that I want to remove and make it partially transparent instead. The image is in PNG format, so I suspect the ...

The absence of the Three.js file in my HTML file is noticeable

Currently, I am diving into HTML5 and experimenting with the Three.js 3D engine. While following a tutorial from this source, it was recommended that I include the three.js file in my HTML document. However, I encountered two files with the same name and d ...

Unable to make the Show/Hide Loading GIF function work as intended

Could someone please help me with my code? I'm trying to display a loading GIF image while waiting for an ajax request to complete. When the button is pressed, I want the loader to be shown until the data is returned from the server. I would greatly ...

Tips for submitting a form using JavaScript without the button causing a page refresh

I am trying to submit a simple form using Ajax, but no matter what I do, the form keeps refreshing the page. My goal is to submit the form with a GET request using JavaScript so that I can receive a JavaScript response from the server. <div id='f ...

Could LXML potentially determine the value of a class in HTML?

For instance, consider the following scenario: <button class="oW_lN oF4XW sqdOP yWX7d _8A5w5 ">MyTextIsHere</button> The "MyTextIsHere" part of the code can contain only two specific values: "Yes" and "No". Is it feasible to determine wh ...

Any suggestions for resolving issues with tipsy, SVG, and CSS on Firefox?

Having difficulty getting tipsy tooltips to display correctly next to the cursor in Firefox for my svg elements generated with d3. I discovered a patch that resolves most of the issues, which I found through this helpful answer about Tipsy tooltip position ...

How can the datepicker be adjusted to display from right to left?

//Initializing the datepicker $('dob').on('click',function(){ $('.datepicker').datepicker({ "format": "dd/mm/yyyy", "autoclose": true }); }); <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstra ...

Differences in layout design when using floats and display: table between Chrome and Firefox can affect the visual appearance

Try out this link on JS Fiddle: https://jsfiddle.net/7p81bnto/2/ Here's the HTML code: <body> <main> <div> <div style=" height: 50px; width: 200px; ...

HTML features various product displays across multiple pages

I am struggling with the terminology for my issues. I am currently working on an e-commerce project aimed at displaying products. My goal is to have only 30 products shown on each page, with product 31-60 displayed on page 2 and product 61-90 displayed on ...