473,500 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CSS substitution for the <center> tag

As most of us probably know, the <centertag is deprecated. Because many
elements and controls have an align attribute, centering them is easy
enough. However, certain elements/controls do not (such as the ASP.NET
Button and Label controls). For the ASP.NET label control I usually just add
the following attributes:

Width="100%" style="text-align:center;"

However, this does not work for controls such as the ASP.NET Button control.
The only solution I can think of is to nest it inside of <div
align="center"></divtags. However, this could add a lot of extra tags. Any
suggestions? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Jan 16 '07 #1
5 2420
<div align='center'>
</div>
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujinionline.com
-----------------------------------------
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
As most of us probably know, the <centertag is deprecated. Because many
elements and controls have an align attribute, centering them is easy
enough. However, certain elements/controls do not (such as the ASP.NET
Button and Label controls). For the ASP.NET label control I usually just
add the following attributes:

Width="100%" style="text-align:center;"

However, this does not work for controls such as the ASP.NET Button
control. The only solution I can think of is to nest it inside of <div
align="center"></divtags. However, this could add a lot of extra tags.
Any suggestions? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Jan 16 '07 #2
As I said in my original message, I have used that, but would like to have a
way that does not involve any extra tags (in other words, I would like to do
it using CSS). Any other ideas? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Gaurav Vaish (MasterGaurav)" <ga*****************@nospam.gmail.comwrote
in message news:%2****************@TK2MSFTNGP02.phx.gbl...
<div align='center'>
</div>
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujinionline.com
-----------------------------------------
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>As most of us probably know, the <centertag is deprecated. Because many
elements and controls have an align attribute, centering them is easy
enough. However, certain elements/controls do not (such as the ASP.NET
Button and Label controls). For the ASP.NET label control I usually just
add the following attributes:

Width="100%" style="text-align:center;"

However, this does not work for controls such as the ASP.NET Button
control. The only solution I can think of is to nest it inside of <div
align="center"></divtags. However, this could add a lot of extra tags.
Any suggestions? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/


Jan 16 '07 #3
Do you mean aligning the text inside a button? Aligning with
style="text-align:xxx" does work for this.And the text is already centered
by default. Do you mean something else?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
As most of us probably know, the <centertag is deprecated. Because many
elements and controls have an align attribute, centering them is easy
enough. However, certain elements/controls do not (such as the ASP.NET
Button and Label controls). For the ASP.NET label control I usually just
add the following attributes:

Width="100%" style="text-align:center;"

However, this does not work for controls such as the ASP.NET Button
control. The only solution I can think of is to nest it inside of <div
align="center"></divtags. However, this could add a lot of extra tags.
Any suggestions? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Jan 16 '07 #4
No, I am referring to horizontally centering the button on the page (or
within the div, td, or other tag that it is contained in). Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:OP**************@TK2MSFTNGP04.phx.gbl...
Do you mean aligning the text inside a button? Aligning with
style="text-align:xxx" does work for this.And the text is already centered
by default. Do you mean something else?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>As most of us probably know, the <centertag is deprecated. Because many
elements and controls have an align attribute, centering them is easy
enough. However, certain elements/controls do not (such as the ASP.NET
Button and Label controls). For the ASP.NET label control I usually just
add the following attributes:

Width="100%" style="text-align:center;"

However, this does not work for controls such as the ASP.NET Button
control. The only solution I can think of is to nest it inside of <div
align="center"></divtags. However, this could add a lot of extra tags.
Any suggestions? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/


Jan 16 '07 #5
Nathan Sokalski napisał(a):
No, I am referring to horizontally centering the button on the page (or
within the div, td, or other tag that it is contained in). Thanks.
According to css specifications text-align:center should only center
text content of element. What you want achieve, is done with margin: auto;
IE of course doesn't support it:(
other browsers (opers, firefox, safari) supports it.

In IE you should apply text-align:center to parent element of your
button, because IE applies centering to all content (not only text).
If you don't want to center all content - apply text-align:left to
content which you don't want to center.
--
PP
Jan 17 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4695
by: The Plankmeister | last post by:
Hi... What's an equivalent of doing: <center>hello!</center> in 4.01 strict? I'm using stylesheets and am telling the various selectors I want to be centred to "text-align : center;" but...
34
10968
by: Mark Moore | last post by:
It looks like there's a pretty serious CSS bug in IE6 (v6.0.2800.1106). The HTML below is validated STRICT HTML 4.01 and renders as I would expect in Opera, FrontPage, and Netscape. For some...
4
2208
by: Dan | last post by:
Hi, I would just like to know if the istream operator takes only one parammeter(object) at a time (like z) ? istream operator>>(istream& in, Shape &z) Cause I keep getting error concerning the...
9
3118
by: Julia Briggs | last post by:
How do I construct a <iframe> or equivalent for FireFox/NS browsers, inside a screen centered <div> tag? Can it be done?
1
3111
by: Steve Richter | last post by:
I am using <div align=centerto center a horizontal menu on the page. Problem is the center align of the div is rippling down to the menu items and causing the text of the dynamic popup sub menu...
1
5146
by: jobs | last post by:
I have a simple login page with roughly a 300px x 300px image behind the asp.net login control. I need the login control to land in the middle of the image. I want both the image and the login...
4
2649
by: DiamondEagle | last post by:
Is there a way to center the following div without using the <center> tags? <body bgcolor="#FFFFFF"> <center> <div id="Test" style="background-color:#000000; color:#ffffff; width: 80%;...
13
3265
by: Stevo | last post by:
I've found that for IE6+, if you add the property text-align:center to a DIV, then *anything* inside it gets centered. That can be a table, an object/embed, another DIV, an image, or some text. ...
5
4670
Plater
by: Plater | last post by:
To accomplish what I am looking for (the image centered in it's parent top 'centered') I have done this: <div id="backing"> <div id="lbImgBacker"> <center> <img id="Image1"...
0
7136
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7018
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.