0

enter image description here

How can I place "Comment:" on red line as shown in the above picture? I know it's a little bit of a silly question, but as a beginner it would be helpful for me. Here is a code snippet:

body {
  border: 1px solid black;
  height: 550px;
  width: 550px;
  padding: 5px;
}
h2 {
  text-align: center;
}
<h2>FeedBack Form</h2>
<strong>Name:</strong> 
<input type="text" />
<br>
<br>
<strong>Comment:</strong> 
<input type="text" style="height:100px; width:250px;" />
<br>
<br>
<strong>Email Address:</strong> 
<input type="text" />
jaunt
  • 4,978
  • 4
  • 33
  • 54
Captain
  • 13
  • 3
  • comment on red line? could you please explain it a bit more clearly.. – Lal Sep 29 '15 at 17:28
  • are you trying to add more text above that input field or put text inside that field? Or do you mean you want to move the text 'Comment:' to visually be where that red line is – PhilVarg Sep 29 '15 at 17:29
  • Do you want the 'Comment' text to align with the text box? – Andrew Fan Sep 29 '15 at 17:30
  • Perhaps a duplicate of [this](http://stackoverflow.com/questions/8865458/how-to-align-text-vertically-center-in-div-with-css)? – Tim S. Sep 29 '15 at 17:30

4 Answers4

1

try with this:

<strong>Comment:</strong> <input type="text" style="height:100px; width:250px; vertical-align:top;"/><br><br>

I just added vertical-align: top to you input text.

But as a suggestion, I think you may want to use textarea instead input text. And inline css styles is not a thing I would recommend.

Kristijan Iliev
  • 4,901
  • 10
  • 28
  • 47
1

See this fiddle

Please add vertical-align: text-top; or vertical-align: top; as style for the input.

Add the below given to your CSS

input[type="text"]{
        vertical-align: text-top;
}
Lal
  • 14,726
  • 4
  • 45
  • 70
0

Add vertical-align css property

<strong style="vertical-align: top;">Comment:</strong>
rajuGT
  • 6,224
  • 2
  • 26
  • 44
0
<html>
<head>
    <title>FeedBack Form</title>
    <style>
        body {
            border: 1px solid black;
            height:550px;
            width:550px;
            padding:5px;
        }
        h2 {
            text-align: center;
        }
    </style
</head>
<body>
<h2>FeedBack Form</h2>
<strong>Name:</strong> <input type="text" /><br><br>
<strong style="vertical-align: top;">Comment:</strong> <input type="text" style="height:100px; width:250px;"/><br><br>
<strong>Email Address:</strong> <input type="text" />
</body>
</html>
4ra
  • 219
  • 1
  • 2