Skip to content

Instantly share code, notes, and snippets.

@Aravin
Last active February 8, 2023 18:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Aravin/16f5d1f7a1b988e024788fa20b579907 to your computer and use it in GitHub Desktop.
Save Aravin/16f5d1f7a1b988e024788fa20b579907 to your computer and use it in GitHub Desktop.
Aligning a label and textbox horizontally in HTML using CSS
<!DOCTYPE html>
<html>
<head>
<title>Centering a form</title>
</head>
<body>
<div class="form">
<label>Name</label>
<input type="text" name="name">
<label>Email</label>
<input type="text" name="email">
<label>Phone</label>
<input type="text" name="phone">
</div>
</body>
</html>
<style type="text/css">
.form {
margin: 0 auto;
width: 210px;
}
.form label{
display: inline-block;
text-align: right;
float: left;
}
.form input{
display: inline-block;
text-align: left;
float: right;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment