Last active
February 8, 2023 18:34
-
-
Save Aravin/16f5d1f7a1b988e024788fa20b579907 to your computer and use it in GitHub Desktop.
Aligning a label and textbox horizontally in HTML using CSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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