Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Line space / break between tables
Old 06-25-2005, 06:07 PM Line space / break between tables
Experienced Talker

Posts: 32
Trades: 0
Hello all

How could i leave a space between 2 tables?

eg

<table width="100%" border="1" bordercolor="red" cellspacing="0" </table>
<tr>
<td> hello all </td>
</tr>

space here

<table width="10%" border="1" bordercolor="blue" cellspacing="0" </table>
<tr>
<td> Menu's</td>
</tr>

i have tried <br> and <p> with no joy

Sorry im still n00b
zerox3k is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-25-2005, 07:17 PM
celticbrue's Avatar
Extreme Talker

Posts: 175
Location: Wiltshire, England
Trades: 0
Hi zerox,

Your code is a little bit off as you are closing the table </table> before you have finished opening it. The following would be the correct way to produce two tables, one after the the other:

HTML Code:
<table width="100%" border="1" bordercolor="red" cellspacing="0">
<tr>
<td> hello all </td>
</tr>
</table>

<table width="10%" border="1" bordercolor="blue" cellspacing="0"> 
<tr>
<td> Menu's</td>
</tr>
</table>
The above code will give you two tables, one with a red border 100% wide, and a second table 10% wide with a blue border. As the code stands, these tables will (or at least they should), touch each other.

Now, there are a number of options you can use to separate these tables and you weren't too far off with your initial thoughts for two of these methods. Unfortunately, whilst both methods will work, they do not give you very much control over how much space is added between the tables. A single <br> tab will only move the next piece of code down one line (which already happens anyway) and the tables will still touch each other. In order for the line break method to work, you would have to add 2 <br> tags like so:

HTML Code:
<!-- code for first table here-->
</table>

<br><br>

<table width="10%" border="1" bordercolor="blue" cellspacing="0"> 
<!-- code for table 2 goes here -->
Moving on to the paragraph method, you would (I think, because it is a long time since I have coded this way) have to enclose both tables in <p></p> tags like this:

HTML Code:
<p>
<table>
<!-- code for first table here-->
</table>
</p>
<p>
<table>
<!-- code for second table here-->
</table>
</p>
This should create space between the two tables, but again, you will have little or no control over the amount of space produced by the browser.

The way I would do this is to employ something called Cascading Style Sheets (CSS), which is a whole subject in its own right. As you are new to coding, I will keep this very simple and utilise css within the table tags like this:

HTML Code:
<table width="100%" border="1" bordercolor="red" cellspacing="0" style="margin-bottom:10px;">
<tr>
<td> hello all </td>
</tr>
</table>

<table width="10%" border="1" bordercolor="blue" cellspacing="0" style="margin-top:5px;"> 
<tr>
<td> Menu's</td>
</tr>
</table>
The style element lets you set many attributes but in this case, I have restricted it to just the amount of space to be given at the bottom of the first table and the top of the second. By setting both these values, they are added together and in this case will give a gap of 15 pixels between the two tables. You can set them to any value you wish, so play around with what feels and looks right.

Having (hopefully) answered your question, I would urge you to consider the code you are learning as some of the tags you are using are no longer standards compliant (<br> should now be presented as <br />) and there is a big move now to seperate design style from content by using CSS.

The following link should help you get a better idea on HTML, XHTML and CSS and includes loads of tutorials on coding and using these technologies.

w3schools

Hope this has been helpful,
Regards

Ian
__________________
Found this useful? - HIT MY TALKUPATION!


Please login or register to view this content. Registration is FREE
celticbrue is offline
Reply With Quote
View Public Profile
 
Old 06-25-2005, 08:11 PM
Experienced Talker

Posts: 32
Trades: 0
Ian,

Thank you VERY much fo your reply that was excerlant to say the least.

I have been on the w3schools site and it is very good, its just trying to build it all together and take it all in and most of all remember it all lol

I want to try and design a website for my forums and eventually learn a little php and make a database for a load of info were getting together, but because im new i need to start at the bottom like everyone else and learn html, then move on but it will take time and such. Its just a hoby for me so its not like i can spend all day learning

Anyways thanks again so much for your help i will continue learning


One thing i have notied tho is that in the table the border is 1px but thats still allot wider than the lines around this box on the forums and all the lines on the box's here

any idea's why?

Thanks
zerox3k is offline
Reply With Quote
View Public Profile
 
Old 06-25-2005, 09:00 PM
celticbrue's Avatar
Extreme Talker

Posts: 175
Location: Wiltshire, England
Trades: 0
Hi zerox,

That one had me befuddled for a moment (it's late here), but it is because the <td> tags inherit some of the table properties. If you set the border property in the <table> tag, all table cells within that table will be given a border of 1 pixel.

What happens is the border of the table is 1 pixel wide and each table cell (<td></td>) is then automatically given a border of 1 pixel. When you set the cellspacing to zero (cellspacing="0") the table cells butt up to each other and also the outer table border creating a border that is 2 pixels wide.

If you set border="10" in the table tag, the table will have an outer border of 10 pixels and each table cell will have a border of 1 pixel. Again, with cellspacing="0", these borders will touch each other.

If you set cellspacing="1" , you will see what I mean.

The border property cannot be set for the individual <td> tags.

There are two methods you can use to try and get around this. CSS (my favourite as you have probably guessed) or you can create a "virtual" border by doing the following:
HTML Code:
<table cellspacing="1" bgcolor="#800000">
<tr>
  <td bgcolor="#ffffff">100</td>
  <td bgcolor="#ffffff">200</td>
  <td bgcolor="#ffffff">300</td>
</tr>
<tr>
  <td bgcolor="#ffffff">400</td>
  <td bgcolor="#ffffff">500</td>
  <td bgcolor="#ffffff">600</td>
</tr>
</table>
The cellspacing acts as a border to allow the table background colour to show through. If you don't specify the <td> background colour for each <td> tag, it will inherit the bgcolor property of the table.

Glad I could be of some help. I do still remember how difficult it was getting started and to be honest, if you stick at it and keep wanting to get better, I don't think there are any of us who will ever stop learning new tricks of the trade in some form or another.

Regards
Ian

PS I'm off to bed now - its almost 2 AM!
__________________
Found this useful? - HIT MY TALKUPATION!


Please login or register to view this content. Registration is FREE
celticbrue is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Line space / break between tables
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.41320 seconds with 12 queries