The proper alignment of text boxes is not working properly.I tried using align-left right etc but not working.

2 Answers

Ravi Sharma On

---You should take algn:right in div because in textbox align property does not work, and in textbox you should take float:right property, below is my code, check it-----

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <div style="width:30%">
            <asp:TextBox ID="txtName" runat="server" Style="float:right"></asp:TextBox>
        <br /><br />
        <div style="width:30%" align="right">
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

enter image description here

AhmadMM On

Basically you have 2 methods,

  1. ASP.NET TextBox control, as in <asp:textbox .. align="left|right|center"></asp:textbox>
  2. You can use css style to align any element you desire [RECOMMENDED]

As an example of CSS Alignment

/* Keyword values */
float: left;
float: right;
float: none;
float: inline-start;
float: inline-end;

/* Global values */
float: inherit;
float: initial;
float: unset;


.alignleft {
 float: left; 
    display: inline;
.alignright {
float: right;
    display: inline;
<div id="textbox">
  <p class="alignleft">Text on the left.</p> 
  <p class="alignright">Text on the right.</p>