473,386 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Center a table in asp.net 2.0?

Kat
How do you center a table in visual studio 2005? It used to be align=center
but now it tells me it is an out of date method.
Apr 2 '07 #1
7 18325
On Apr 2, 12:57 pm, "Kat" <KatMagicB...@yahoo.comwrote:
How do you center a table in visual studio 2005? It used to be align=center
but now it tells me it is an out of date method.
Just to make sure I'm understanding:

<table align="center">
<tr>
<td>blah</td>
<td>boo</td>
</tr>
</table>

You're trying to do something like that, correct?

align=center is a deprecated HTML table property. All table alignment
and formating should be done through CSS (Cascade Style Sheets). In
your style sheet, add this:

..tableClass { margin:0 auto; }

If you want to put it directly into your table, do this:

<table style="margin:0 auto">

What that is doing is saying I want the top and bottom margins to my
table (the space between your table and its surrounding objects) to be
0, but I want you to auto distribute the appropriate widths to the
sides.

Hope this helps.

Apr 2 '07 #2
You have to CSS style sheet and implement there and use class attribute to
specify style name or change the DOCType model to "Traditional" ...

Raj

"Kat" wrote:
How do you center a table in visual studio 2005? It used to be align=center
but now it tells me it is an out of date method.
Apr 2 '07 #3
align="center" can still be used without any issues if you are using HTML or
XHTML Transitional (which are the most common forms of HTML and XML).
align="center" is considered to be deprecated by the World Wide Web
Consortium or W3C (the people who set the standards for HTML and other
technologies) and has been for about a decade, so using it in earlier
versions of .NET would still have put it in the deprecated "camp".

Because so many millions of web pages use the align attribute, the W3C
created a "flavor" of HTML which still allows for its use, the
"Transitional" flavor. If you are using this, then there is no problem
using align.

If you want to follow the "Strict" flavor, which says that align is
deprecated and can't be used, then you must use Cascading Style Sheets (CSS)
to do this:

<table id="something" style="margin-left: auto; margin-right: auto;">

Refer to these following links for more info:

http://www.captain.at/howto-css-hori...-alignment.php
http://www.gtalbot.org/NvuSection/Nv...Alignment.html

-Scott
"Kat" <Ka**********@yahoo.comwrote in message
news:Ov**************@TK2MSFTNGP03.phx.gbl...
How do you center a table in visual studio 2005? It used to be
align=center but now it tells me it is an out of date method.

Apr 2 '07 #4
Kat wrote:
How do you center a table in visual studio 2005? It used to be align=center
but now it tells me it is an out of date method.

I do it like this:

<div style="text-align:center">
<asp:Table ID="Table1" runat="server" >
etc...

But I'm new to this, so if this is an inferior way to go, someone please
point it out.

Also, what is telling you when you're using an 'out of date method'?
I'd like to get that warning too, but my compiler doesn't flag these
obsolete things I might have put in. thanks
Apr 3 '07 #5
That code won't work. text-align is for aligning text, not tables.
"James Irvine" <ja************@msn.comwrote in message
news:13*************@corp.supernews.com...
Kat wrote:
>How do you center a table in visual studio 2005? It used to be
align=center but now it tells me it is an out of date method.

I do it like this:

<div style="text-align:center">
<asp:Table ID="Table1" runat="server" >
etc...

But I'm new to this, so if this is an inferior way to go, someone please
point it out.

Also, what is telling you when you're using an 'out of date method'? I'd
like to get that warning too, but my compiler doesn't flag these obsolete
things I might have put in. thanks

Apr 3 '07 #6
Scott M. wrote:
That code won't work. text-align is for aligning text, not tables.
Thanks. I'm re-writing my code as we speak. So how do I avoid
accidentally putting in deprecated code?

I added <xhtmlConformance mode="Strict" /to my Web.config file, but
it doesn't flag deprecated code (i.e. <center>) at compile time. Is
there a way I can be warned upfront about this?
Apr 3 '07 #7
HTML is not compiled code, so don't expect any compiler to tell you about
it.

Instead, add the appropriate DOCTYPE tag to your HTML or XHTML code, set the
schema for your page to validate against to the desired one and watch for
the red-wavy underlines in your HTML.

Having said that, as I stated earlier, there is nothing wrong with using
Transitional, which allows deprecated tags.

"James Irvine" <ja************@msn.comwrote in message
news:13*************@corp.supernews.com...
Scott M. wrote:
>That code won't work. text-align is for aligning text, not tables.

Thanks. I'm re-writing my code as we speak. So how do I avoid
accidentally putting in deprecated code?

I added <xhtmlConformance mode="Strict" /to my Web.config file, but it
doesn't flag deprecated code (i.e. <center>) at compile time. Is there a
way I can be warned upfront about this?

Apr 3 '07 #8

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

Similar topics

10
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
0
by: PayPal | last post by:
<HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft DHTML Editing Control"> <TITLE></TITLE> </HEAD> <BODY> <STYLE type=text/css> ..dummy {} BODY, TD {font-family:...
2
by: googley | last post by:
I'm starting a new thread for a problem that I ran into.. I'm trying to use STYLE SHEETS/CSS to update multiple table widths across many pages. I did get it working with one small problem that...
7
by: ALI-R | last post by:
Hi All, I have two user controls (header and footer) ,,which I've placed in an HTML Table in a page.I set the **align="center"** in the table and the table still is on the left side of the page...
7
by: charlies224 | last post by:
Hi, I have been searching for a way to display my whole web page at the center of the browser. Basically, I created a web application and created a web form with a table in it. I tried the...
3
by: jaiwin | last post by:
I am insert a div tag in table. table width is 100%. div width is 500px. i want to center alignment in div tag. so which command i want to use this <table align="center" border="0"...
2
by: yangtono | last post by:
Hi, I am creating a table to list some data. The table is using a sorting and highlight function that I found from the net. I can't attach image here, basically html will wrap the heading,...
14
by: gaijinco | last post by:
I was a hobbist web coder for years but I had to sidestep for a while. Now I'm trying to return to it and I'm trying to clarify how am I supposed to do somethings with CSS v.s. HTML and I'm...
13
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. ...
8
by: Bob Altman | last post by:
Hi all, This has got to be a dumb question, but... What is the CSS property that I would use to center a table on the web page? If I set the table's Align property in the VS 2008 property...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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,...

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.