Reputation: 501
I am relatively new to HTML.
I want to get a border around form elements which are similar.
For example, for Sign Up form :
How can I do this?
Upvotes: 11
Views: 13510
Reputation: 808
The tag you are looking for is <fieldset>
<fieldset style="width:270px">
<legend>Contact details</legend>
<label>Name:<br /></label>
<input type="text" name="name"><br />
<label>Email:<br />
<input type="text" name="email"></label><br />
<label>Mobile:<br />
<input type="text" name="mobile"></label><br />
</fieldset>
The result would be something like this :
And whatever is there in your legend
tag is going to be displayed in the box as heading for the group.
The width determines the size of the box. If no width is mentioned, or you haven't used any CSS, the size of the rectangle would be that of the browser window.
Upvotes: 11
Reputation: 1719
<!DOCTYPE html>
<html>
<body>
<form>
<fieldset>
<legend>Sign up:</legend>
<label>Name:</label>
<br>
<input type="text" name="name"/><br>
<label>Email: </label>
<br>
<input type="email" name="email"/><br>
<label>Date of birth:</label>
<br>
<input type="text" name="dob"/>
</fieldset>
</form>
</body>
</html>
Upvotes: 0
Reputation: 41
The way you can do this is:-
<fieldset>
<legend>Contact details</legend>
<label>Email:<br />
<input type="text" name="email" /></label><br />
<label>Mobile:<br />
<input type="text" name="mobile" /></label><br />
<label>Telephone:<br />
<input type="text" name="telephone" /></label>
</fieldset>
Upvotes: 0
Reputation: 615
do you mean something like this?
<!DOCTYPE html>
<html>
<body>
<form>
<fieldset>
<legend>Personalia:</legend>
Name: <input type="text"><br>
Email: <input type="text"><br>
Date of birth: <input type="text">
</fieldset>
</form>
</body>
</html>
Demo here: https://jsfiddle.net/991avcmv/
Upvotes: 4