|
-
Mar 18th, 2002, 04:00 AM
#1
Thread Starter
PowerPoster
CSS Tables, Table Align
Howdy doo
I've created a new (offline) website using standard html and it looks good enough to attract women but I was thinking to myself that I might take a look at this CSS stuff. Well, it all looks pretty straightforward but I have one 'conceptual' question and one 'technical' question
• Is the use of Tables still acceptable in CSS and if acceptable is it best practice? (I read a bit about positioning 'blocks')
• If Tables are the way to go how is it possible to centre align a table (the whole table) on the page. There is no align attribute of Tables in css and I have tried other answers that i found (margin_left/right: auto) but that didnt work either. Any ideas???
Ta muchly.
-
Mar 18th, 2002, 04:28 AM
#2
Fanatic Member
1/ Tables is still acceptable because CSS still has no acceptable way of creating tables, at least not until the new version arrives. You can use the <span> or <div> HTML Tag and use CSS to align it but I think this is really fiddly at times
2/ Yes it is. You cane either use align="center" in the table tab (shown in code below) or you can put the whole table in <center> </center> tags.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Quick Tables Question</title>
</head>
<body>
<table border="1" width="50%" align="center">
<tr align="center">
<td>Column 1</td>
<td>Column 2</td>
</tr>
<tr align="center">
<td>Column 1</td>
<td>Column 2</td>
</tr>
</table>
</body>
</html>
But I advise you to give CSS/DHTML a go, you might like it
-
Mar 18th, 2002, 04:33 AM
#3
Thread Starter
PowerPoster
• Thks for ur answer. I understand that u can use the table align tags within the html page but why is it that u cant set it in the css file like u can with all other table attributes? Is it normal to set all attributes in css and still do this...
<table class="blugh" align="center"> .....
• When u say Css/dhmtl .. i take it that u still mean css version 2? k? Yeah i do want to use it but is only an hour since i decided to .. it looks pretty easy but will take a little getting used to
-
Mar 18th, 2002, 05:15 AM
#4
Fanatic Member
Its probably better practice to use CSS to align text in a table.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Quick Tables Question</title>
<style type="text/css">
<!--
table {text-align: center}
-->
</style>
</head>
<body>
<table border="1" width="50%" center="align">
<tr>
<td>Column 1</td>
<td>Column 2</td>
</tr>
<tr align="center">
<td>Column 1</td>
<td>Column 2</td>
</tr>
</table>
</body>
</html>
DHTML is a a mixture of CSS/HTML and Javascript/VBScript. Basically, you use CSS for page layout or the HTML tags and you use a scripting language to controll and dynamic user input, hence Dynamic Hypertext Markup Language
-
Mar 18th, 2002, 05:29 AM
#5
Thread Starter
PowerPoster
thanks but i dont think that u are answering the question I asked. i am not concerned with the text alignment but with how the table appears on the screen. u have set text align in css and then used table align in html. I am asking if u can use some method to align the table (not the text) in css rather than having to do it in html.
-
Mar 18th, 2002, 05:44 AM
#6
Fanatic Member
Sorry, yeah, I mis-read the question. Anyhoo... according to CSS specifications the suggested way to center a table is to set the left and right margins to auto. But I dont think this works most of the time.
The best way (In my opinion) is to put the table in a Div and center the Div like this : -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Quick Tables Question</title>
<style type="text/css">
<!--
div.centered {text-align: center;}
div.centered table {margin: auto; text-align: center;}
-->
</style>
</head>
<body>
<div class="centered">
<table border="1" width="50%">
<tr>
<td>Column 1</td>
<td>Column 2</td>
</tr>
<tr align="center">
<td>Column 1</td>
<td>Column 2</td>
</tr>
</table>
</div>
</body>
</html>
...which works fine in IE and Netscape.
-
Mar 18th, 2002, 06:06 AM
#7
Thread Starter
PowerPoster
Cool thanks
-
Mar 19th, 2002, 12:16 PM
#8
Black Cat
Re: CSS Tables, Table Align
Originally posted by beachbum
Howdy doo
I've created a new (offline) website using standard html and it looks good enough to attract women but I was thinking to myself that I might take a look at this CSS stuff. Well, it all looks pretty straightforward but I have one 'conceptual' question and one 'technical' question
• Is the use of Tables still acceptable in CSS and if acceptable is it best practice? (I read a bit about positioning 'blocks')
In theory, with CSS, you should only use tables for presenting tabular data, not for layout/presentation. In reality, lots of people are going to use tables anyway. Do a search for "table-less CSS layout" or related terms and you should get some interesting links.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|