howto center text in a web form's textbox?

I opened up my project.. and I saw a Styles.css.. I assume that all asp.net/vb.net projects have the styles.css in them as default?

And the style sheets are already utilized?
 
Nm.. got it.. very easy..
Just drag 'styles.css" to the aspx project..and then styles.css is enabled :)

But.. How do I center the label txt using stylesheets?
 
Google CSS .... for future ref.

To answer your question. Give yourself a class in the style sheet for the things you want to have center aligned. Then in that class use the text-align property and set it to center:

.centerText
{
text-align: center;
}

Again, Google CSS, it will help.
 
Actually.. my problem was something I wasn't explaining right.. the label was 300px wide.. and i wanted the txt inside the label to be centered.

So what i did was just set the label to nothing px wide.

then centered it. (with css or <center></center>)
 
Also.. I still don't know how to apply .centerText to just this:

<P><asp:label id="errormsg" runat="server" Height="32px" ForeColor="Red"></asp:label></P>

Ideas?

/ps.. using <center></center> results in this errror msg:
The World-Wide-Web Consortium now regards the element 'center' as outdated. Newer constructs are recommended.
 
I can center fields with CSS..

But I need to center the text inside a label field..
I cannot just center the label field (because it has to be justified right)


any ideas?

thanks
Lee
 
Last edited:
Back
Top