Is there a way to align the Login and Register buttons next to each other? I specifically want the Register button to redirect to the register.php page using HTML/CSS

Is there a way to align login and register buttons side by side using HTML and CSS? I want the register button to redirect to register.php

I attempted to create a register button with the <input> element, but I couldn't get them to display next to each other. Using display:inline; did not work as well.

*{
    font-family: 'Montserrat', sans-serif;

}

body,
html{
    margin: 0px;
    padding: 0px;
    background-color: #0E0E0E;
}

.login-box{
    background-color: #010100;
    width: 400px;
    height: 388px;
    margin: 250px auto;
}

.login-box h1{
    color: #FFFFFF;
    margin:0px 35px;
    margin-bottom: 35px;
    padding-top: 25px;
}

.login-box form input{
    display: block;
    width: 324px;
    height: 50px;
    margin-left: 35px;
    margin-right: 41px;
    margin-bottom: 24px;
}

#submit{
    display: inline;
    color: #010100;
    background-color: #E4FF77;
    border: 2px solid transparent;
    border-radius: 12px;
    width: 150px;
    height: 50px;
    margin-left: 24px;
    margin-right: 41px;
    margin-bottom: 33px;
}

#pwdreset{
    display: block;
    color: #FFFFFF;
    text-decoration: none;
    margin: 20px 0px;
    margin-left: 225px;
}

#register-button {
    display: inline;
    color: #010100;
    background-color: #E4FF77;
    border: 2px solid transparent;
    border-radius: 12px;
    width: 150px;
    height: 50px;
    margin-left: 24px;
    margin-right: 41px;
    margin-bottom: 33px;
}
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="signin.css">
        <link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
        <title>Agreya - Login</title>
    </head>

    <body>

        <div class="login-box">

            <h1>Login</h1>

            <form class="login-form" action="login.php" method="post">
                <input id="username" type="text" name="username" placeholder="Email" >
                <input id="password" type="password" name="password" placeholder="Password">
                <a id="pwdreset" href="#">Forgot password?</a>
                <input id="submit" type="submit" name="submit" value="Login">
            </form>

            <form action="https://www.w3docs.com/">
                <input id="register-button" type="submit" name="register" value="Register">
            </form>

        </div>

    </body>


</html>

Answer №1

Is this the optimization you seek?

* {
  font-family: 'Montserrat', sans-serif;
}

body,
html {
  margin: 0px;
  padding: 0px;
  background-color: #0E0E0E;
}

.login-box {
  background-color: #010100;
  width: 400px;
  height: 388px;
  margin: 250px auto;
  position: relative;
}

.login-box h1 {
  color: #FFFFFF;
  margin: 0px 35px;
  margin-bottom: 35px;
  padding-top: 25px;
}

.login-box form input {
  display: block;
  width: 324px;
  height: 50px;
  margin-left: 35px;
  margin-right: 41px;
  margin-bottom: 24px;
}

#submit {
  display: inline;
  color: #010100;
  background-color: #E4FF77;
  border: 2px solid transparent;
  border-radius: 12px;
  width: 150px;
  height: 50px;
  position: absolute;
  bottom: 0;
}

#pwdreset {
  display: block;
  color: #FFFFFF;
  text-decoration: none;
  margin: 20px 0px;
  margin-left: 225px;
}

#register-button {
  display: inline;
  color: #010100;
  background-color: #E4FF77;
  border: 2px solid transparent;
  border-radius: 12px;
  width: 150px;
  height: 50px;
  position: absolute;
  bottom: 0;
  right: 0;
}
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">

<div class="login-box">

  <h1>Login</h1>

  <form class="login-form" action="login.php" method="post">
    <input id="username" type="text" name="username" placeholder="Email">
    <input id="password" type="password" name="password" placeholder="Password">
    <a id="pwdreset" href="#">Forgot password?</a>
    <input id="submit" type="submit" name="submit" value="Login">
  </form>

  <form action="https://www.w3docs.com/">
    <input id="register-button" type="submit" name="register" value="Register">
  </form>

</div>

Answer №2

Utilize the formaction attribute and place both buttons within the same form as shown below.
This code is compliant with HTML5 standards and functions properly in Internet Explorer versions 10 and above.

    <form class="login-form" action="login.php" method="post">
        <input id="username" type="text" name="username" placeholder="Email" >
        <input id="password" type="password" name="password" placeholder="Password">
        <a id="pwdreset" href="#">Forgot password?</a>
        <input id="submit" type="submit" name="submit" value="Login">
        <input formaction="/register.php" id="register-button" type="submit" name="register" value="Register" >
    </form>            
    

Answer №3

My suggestion is to include position: relative; in the class: .login-box.

Additionally, assign a class to your registration form such as:

.form-2{
  position:absolute;
  bottom: 0;
  right:0;
}

Answer №4

Combine your second form and button within the first form inside a new div with a flex display style, creating side-by-side buttons.

* {
  font-family: "Montserrat", sans-serif;
}

body,
html {
  margin: 0px;
  padding: 0px;
  background-color: #0e0e0e;
}

.login-box {
  background-color: #010100;
  width: 400px;
  height: 388px;
  margin: 250px auto;
}

.login-box h1 {
  color: #ffffff;
  margin: 0px 35px;
  margin-bottom: 35px;
  padding-top: 25px;
}

.login-box form input {
  display: block;
  width: 324px;
  height: 50px;
  margin-left: 35px;
  margin-right: 41px;
  margin-bottom: 24px;
}

#submit {
  display: inline;
  color: #010100;
  background-color: #e4ff77;
  border: 2px solid transparent;
  border-radius: 12px;
  width: 150px;
  height: 50px;
  margin-left: 24px;
  margin-right: 41px;
  margin-bottom: 33px;
}

#pwdreset {
  display: block;
  color: #ffffff;
  text-decoration: none;
  margin: 20px 0px;
  margin-left: 225px;
}

#register-button {
  display: inline;
  color: #010100;
  background-color: #e4ff77;
  border: 2px solid transparent;
  border-radius: 12px;
  width: 150px;
  height: 50px;
  margin-left: 24px;
  margin-right: 41px;
  margin-bottom: 33px;
}

.submits {
  display: flex;
}
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="main.css">
        <link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
        <title>Agreya - Login</title>
    </head>

    <body>

        <div class="login-box">

            <h1>Login</h1>

            <form class="login-form" action="login.php" method="post">
                <input id="username" type="text" name="username" placeholder="Email" >
                <input id="password" type="password" name="password" placeholder="Password">
                <a id="pwdreset" href="#">Forgot password?</a>
                <div class="submits">

                  <input id="submit" type="submit" name="submit" value="Login">
                  <form action="https://www.w3docs.com/">
                    <input id="register-button" type="submit" name="register" value="Register">
                </form>
                </div>
            </form>

            

        </div>

    </body>


</html>

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

Span tag not respecting CSS width property

One of my spans is causing an issue. Here are the styles in question: .form_container .col1che { float: left; width: 4%; text-align: left; } .form_container .col2che { float: left; width: 80%; text-align:left; } .form_container .col3che { float: ...

The feature of interpolation within attributes has been eliminated. Please use either v-bind or the colon shorthand in its place

I am struggling to grasp how I can pass a value to Vue using HTML. I keep encountering this error message: Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. Edit: I am trying to pass the value "country" to the Vu ...

Transforming traditional HTML table layout to modern div structure

We are currently in the process of transitioning old pages from our previous website structure, which used tables, to our new layout based on DIVs. Our website is structured using a PHP include system with separate components for the header, body, and foot ...

Gather information that is dynamic upon the selection of a "li" option using Python Selenium

I need to extract data from this website (disregard the Hebrew text). To begin, I must choose one of the options from the initial dropdown menu below: https://i.stack.imgur.com/qvIyN.png Next, click the designated button: https://i.stack.imgur.com/THb ...

Adaptive video player for complete YouTube experience

Is there a way to incorporate a YouTube video as the background of a div, similar to how it is done on this site, using a <video> tag and ensuring that the video "covers" the entire div without any empty spaces while maintaining its original ratio? ...

Is there a method to trigger click events on overflow content when clicked?

I am currently tackling a significant issue: I need the drop-down options' width to be wider than where the selected value is displayed, especially in IE7. After conducting some research on Google, I decided to take matters into my own hands and write ...

Image encoded in base64 not appearing on the screen

Hey there, I'm currently working on implementing a jQuery image uploader that generates a base64 code when an image is selected. function readImage(input) { if (input.files && input.files[0]) { var FR= new FileReader(); FR.onload ...

What is the best way to delete the text following the last "/" in location.href with the help of

I need to extract #step_4#step_4#step_4 from the local project URL The link is https://localhost/test-project/#step_4#step_4#step_4, and I aim to achieve this using window.location.href. This is the code snippet I have implemented: var url_id = window.lo ...

How to Ensure that the Hidden Value of Select Statement in Angular is Always Displayed as Text

Is there a way to customize the top part of a dropdown menu so that it always displays a specific phrase, like 'Symbols' in this case, regardless of the option selected? Currently, the top part shows the last selected symbol, but I want it to be ...

When the width of the element is set to 100vw, it disrupts the

I'm attempting to expand a sticky element to fit the size of the screen. Here is the HTML code I am using: .large { height: 200vw; width: 200vw; } .header { left: 0; top: 0; color:white; position: sticky; width: 100px; height: 10 ...

Using Python and Selenium to retrieve information from the attribute 'data-label'

https://i.stack.imgur.com/zb7f5.jpg try: details = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "DataTables_Table_5")) ) scores_list = details.find_elements_by_tag_name('tbody') for sco ...

The height of the input element is greater than the size of the font

I am facing an issue with an input element that has a height 2px higher than what I expected. Here is the relevant CSS: .input { font-size: 16px; padding: 15px; border: 1px solid black; border-radius: 3px; width: 400px; } <input class=" ...

The process of transforming four columns into two columns and two rows

I am aiming to create a layout that displays 4 columns on desktop and then breaks down into 2 columns and 2 rows on smaller screens. https://i.stack.imgur.com/GZ4nQ.png https://i.stack.imgur.com/5ZCrQ.png Any suggestions on how I can achieve this layout ...

Modify the background color of the <li> element without using JavaScript after 3 seconds

Is it possible to change the background color of a <li> element without using javascript or JQuery, only with CSS? I've seen incredible things done with CSS alone and believe this is achievable. My <li> element functions as a horizontal m ...

My divs seem to overlap in strange, unpredictable ways depending on the zoom level - it's an odd phenomenon that occurs

This situation is causing me frustration... depending on the zoom level of the browser, my boxes do not align properly and it ends up looking messy (in all browsers). Any advice? Could I handle this more effectively with jQuery? HTML </div> <div ...

Express, Postgres, and Sequelize throw an error that says "TypeError: Unable to access the 'create' property of undefined."

I am currently working on developing a login system using Express, Postgres, and Sequelize as my ORM. Below is the code snippet: user.js var express = require('express'); var bodyParser = require('body-parser'); var db = require(&ap ...

What is the best way to implement jQuery on my website?

Instead of copying all the example code here, you can check out the jQuery demo page: Demo Page I would like to integrate the Latest News example with scrolling text in red from the demo page into my website. The demo page also provides links to the sour ...

Developing a system mode called "night mode"

I've decided to incorporate a dark mode feature into my Wordpress theme. Creating both dark and light modes was a breeze, but now I want to add a third mode that serves as the default for pages. This new mode will automatically switch between dark a ...

What is causing the failure of the requestQuota call in this filesystem api?

Currently, I am developing an HTML5 application intended to be run on Chrome from the local filesystem. Whenever I attempt to access the filesystem, an error is thrown, possibly due to it being a local file. Is there any way to configure Chrome to allow th ...

Is it possible to place this script above all of my content?

For instance, take a look at this script: I am currently working on designing my own homepage and I would like to include the above script. The homepage will consist of links, buttons, and other content. However, I'm facing an issue where the birds f ...