HTML Form How to - Align text in text input field right








Question

We would like to know how to align text in text input field right.

Answer


<!--from  w w w  .  ja v a 2 s.  co  m-->
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
LABEL {
  display: block;
  width: 300px;
}

BR {
  display: none;
}

INPUT {
  text-align: right;
  float: right;
}
</style>
</head>
<body>
  <label>Name:<br>
  <input type="text" value="" name="name"></label>
</body>
</html>

The code above is rendered as follows: