You should sue the correct semantic tags for accessibility reasons!
Simply remove the default styles of the inputs and textarea. Then add the underline with a border-bottom.
For more details see the inline comments in CSS:
/* removes the default fieldset styling */
fieldset {
border: none;
padding: 0;
}
/* gives the legend the same font-size and weight as the h2 tag */
legend {
font-size: 1.5em;
font-weight: bold;
}
/* gives the underline to a label and input */
fieldset > div {
border-bottom: 1px solid black;
width: 50%;
padding: 0.5em 0;
}
/* gives the label the same font-size and weight as the h3 tag */
label {
font-size: 1.17em;
font-weight: bold;
}
/* removed the default style of the input and textarea */
input:not([type="submit"]),
textarea {
border: none;
background: transparent;
}
/* removes the default style of a textarea */
textarea {
resize: none;
border-bottom: 1px solid black;
width: 100%;
}
<form>
<fieldset>
<legend>Form</legend>
<div>
<label for="name">Name</label><input type="text" id="name" placeholder="Your Name">
</div>
<div>
<label for="email">Email</label><input type="email" id="email" placeholder="Your Email">
</div>
<textarea></textarea>
<input type="submit">
</fieldset>
</form>
h1-h6(headlines) for anything else that an actual title/headline. What you looking for is alabel! Semantics are important for accessibility reasons and have an influence on your SEO rating.