Jump to content

Table help


XHTMLboy

Recommended Posts

Hi i have just started xhtml a month ago and was wondering why is it that when you do a simple table like below, it end's up applying the width to Row 1, Row 4, and Row 7. as i only applyed it to row 2. Help would be really appreciated.<table border="1"><tr><td>Row 1</td><td width="33%">row 2</td></tr><tr><td>Row 4</td><td>Row 5</td></tr><tr><td>Row 7</td><td>Row 8</td></tr></table>

Link to comment
Share on other sites

1. Let's make sure we use the same vocabulary. Rows go from left to right (i.e., row 2 will be below row 1). Columns go up and down.2. One of the limitations of tables is that every table cell in a row will be exactly the same height, and every cell in a column will be the same width. If one cell in a column gets defined, and no other definitions override it, then all cells in that column will have the same width.3. It is possible to marge cells using the colspan attribute. That gives you a little more flexibility.4. If none of that is working for you, you may wish to abandon the table and and organize your elements in a different way, perhaps using <div> elements and CSS to size and position them exactly to your liking.

Link to comment
Share on other sites

Thankyou Deirdre's Dad, i now know that row's go left and right and columns go up and down :), and you can do a new row by ending the row and starting a new one with the </tr> <tr> tag's. But what i'm trying to say is if you have two table data tags with your content in as listing 1.1, and close them with the closeing row tag and closing table, if you go to the first cell and add a width of 33%, why does it not apply it to it and apply it to the one you don't wan't it to apply to, like it apply's it to the second cell but not the first. Thankyou for your help it is very much appreciated. :)<table border="1"><tr><td width="33%">First cell</td> (" When this is loaded in internet explorer 8, it apply's it to second cell not first cell.)<td>Second cell</td></tr></table>

Link to comment
Share on other sites

Do you define the width of the whole table anywhere? Without a defined table width, 33% doesn't really mean anything.
Thankyou, i added 77% in my main starting table tag and that seemed to have done the trick, at the moment i just need to knowwhat % will give me that pasific width on the screen, i would get a book but as i know you can't get books that help you out with persentage.
Link to comment
Share on other sites

Since you've pretty much ignored my comments and questions so far, I think I'll pass.
I haven't ignored your comment's and questions. Thankyou for the advise and for being helpfull. :)
Link to comment
Share on other sites

A width of 77% will give you a table that takes up 77% of the available horizontal space. Do you mind posting the code of your entire page?
I haven't got a page yet, i am just learning xhtml first.
Link to comment
Share on other sites

well, how are you practicing it? On a dry erase board? :) Whatever code you have written you can post on here so we can help you. Even if all your page has is a <body> tag, and you put a table in it, it should take up 77% of the parents width. And if I'm correct, the <body> tag should automatically take up the full width of its container, which would be the window's size. Percentage always have to be relative to something, some sort of discrete value, that's just how they work; webpage or not.

Link to comment
Share on other sites

I haven't got a page yet, i am just learning xhtml first.
You should have a page to practice on... I feel that it helps to actually do, and not just read. Just go to notepad and type:
<html><body><table><tr><td></td></tr></table></body></html>

Then save it as something like "practice.html" or "index.html" Make sure to type the ".html" part though.When that's done, you'll have a page you can mess around with, and code to post! :)

Link to comment
Share on other sites

You should have a page to practice on... I feel that it helps to actually do, and not just read. Just go to notepad and type:
<html><body><table><tr><td></td></tr></table></body></html>

Then save it as something like "practice.html" or "index.html" Make sure to type the ".html" part though.When that's done, you'll have a page you can mess around with, and code to post! :)

If he's just learning (or regardless for that matter), he's might as well learn the right way from the beginning, using <div>'s, margins and padding's, and CSS to place his content within an HTML page. Unless he's using the table for something other than a layout (which he hasn't mentioned yet) then that example could possibly promote bad practices.Also, something that's missing from the example is a DTD and head section. You might was well start getting used to including them in your sites if you expect any sort of reasonable cooperation from browsers like IE and FF to render close to the same thing, through validation. Best practices are best learned from the start, and these are the easiest to implement and the most practical to learn. A simple, straighforward, validating right form the start good example of a test page would be something like this (IMO):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><head>  <title>My HTML Strict Test Page</title>  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>    <div>	<p>My paragraph.  In a div that I can style with CSS to get it do what I want!  I could put tables in here too, and with a width setting on my parent container (the div), I can use percentages with reasonable accuracy.</p>  </div></body></html>

If you need to add tables for tabular data, then putting it into a well structured, CSS positioned and styled website, will be much easier and beneficial to your learning experiences.

Link to comment
Share on other sites

why would you give him a table example? No head section? :)If he's just learning (or regardless for that matter), he's might as well learn the right way from the beginning, using <div>'s, margins and padding's, and CSS to place his content within an HTML page.Also, another thing that's missing from the example is a DTD. You might was well start getting used to including them in your sites if you expect any sort of reasonable cooperation from browsers like IE and FF to render close to the same thing, along with validation. Best practices are best learned from the start, and these are the easiest to implement and the most practical to learn.
I think he gave a table example because the title of this thread is 'Table help' but yes you are correct. Divs, margins, padding, and such should be used instead of tables. [EDIT] For content that is. If you have tabular data then by all means, use a table. [/EDIT]On the DTD topic, you may as well make it a Strict DTD. Any DTD is better than no DTD but a Strict DTD is best.
Link to comment
Share on other sites

I think he gave a table example because the title of this thread is 'Table help' but yes you are correct. Divs, margins, padding, and such should be used instead of tables. [EDIT] For content that is. If you have tabular data then by all means, use a table. [/EDIT]On the DTD topic, you may as well make it a Strict DTD. Any DTD is better than no DTD but a Strict DTD is best.
I must have been re-editing my post when you typed this. I have modified my post to reflect my re-evaluating the topic while working on my previous/current post. Complete with a little less flare for the dramatic :)
Link to comment
Share on other sites

Yep. I took "table help" literally and produced that example, but agree with you scientist. Anyways, back to the matter of hand of helping this young chap with his tables!

Link to comment
Share on other sites

Yep. I took "table help" literally and produced that example, but agree with you scientist. Anyways, back to the matter of hand of helping this young chap with his tables!
One other thing that has been bothering me, sorry to be a pain by keep asking you questions but, in what order do i need to learn languages in?, Say at the moment i am learning xhtml, should i learn php or javascript or css next. Sorry i am saying this in the table help thred, but i don't wan't to be a pain in the ###### by making a new thred as i don't know how to delete them, as i just wan't to know what should i learn first out of them to make it a bit more simple.
Link to comment
Share on other sites

You should learn CSS in parallel with HTML, ideally. They provide the foundation for building standards-compliant, fully validating websites.The toss up lies in learning JavaScript or PHP. It's tough to say because they're both equally as useful, but do completely different tasks on the web. PHP is more for interacting with databases and runs only on the server-side (meaning it can only be run on a localhost/server that supports PHP) and JavaScript runs exclusively on the client side (in the browser) buts lets you do a lot of cool stuff, most notably through the use of jQuery libraries. My suggestion is to read the tutorials for both of them and then see what interests you more. If you really get into this kind of stuff though, you will probably be best served by learning both, especially with the advent of AJAX. That's a fun one too.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...