problem in HTML Table "border=0" it takes space

admin

Administrator
Staff member
Hello,

I will give the sample code of html. Here first table only apply border 1 width. other tables are border 0. The problem is border=0 means border was not visible but it takes white border space. I want to remove this space. How can I solve?

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border=1><tr><td>
<table border=0><tr><td>
<table border=0><tr><td>
<table border=0><tr><td>
<table border=0><tr><td>
<table border=0><tr><td>
MY TEST
</td></tr></table>
</td></tr></table>
</td></tr></table>
</td></tr></table>
</td></tr></table>
</td></tr></table>
</div>
</form>
</body>
</html><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
MY TEST
</div>
</form>
</body>
</html>Hello,

But I use the html page as table tag. I was give the sample code only. I want to remove table border space if I am set the attribute border=0.border=0 is depreciated code.

you should be useing style="border:0;" but even that isn't best practice as its still inline styles.

i suggest you STOP NOW! with what you are doing and do some WELL needed tutorials.
<!-- m --><a class="postlink" href="http://www.w3schools.com/html/default.asp">http://www.w3schools.com/html/default.asp</a><!-- m --> - simple html tutorial
<!-- m --><a class="postlink" href="http://www.w3schools.com/xhtml/default.asp">http://www.w3schools.com/xhtml/default.asp</a><!-- m --> - simple xhtml tutorial
<!-- m --><a class="postlink" href="http://www.w3schools.com/css/default.asp">http://www.w3schools.com/css/default.asp</a><!-- m --> - simple CSS tutorial

in the web development world now we separate presentation and content using style sheets.

click on my signature or some of the other members of the forums signatures and view their source code and you will see how websites are supposed to be coded now days.

HTML is to MARKUP (mark headings with heading tags, tables are for tabular data only etc...)
CSS is for presentation/layout
and when you get into serverside languages databases are for handling contentThere is never any need to remove borders from tables where tables are being used correctly in the page. If your table needs the borders removed then you should remove the table completely and use the correct markup for the content.

Where there is a legitimate use of tables (displaying tabular data) the chances of needing to nest a second table inside the first is less than one in a million and so if you are looking at having one table nested inside another then chances are your design is wrong. There is NEVER a need for three levels of tables (well maybe one in a googleplex) so if you are nesting three levels of tables then your page design is definitely wrong.I'm going to go ahead and assume those 72098530 tables you put above were to show us an example that nested tables still take up 'border' space even when there border is set to 0. And I'm also going to go ahead and assume that you would never use anything like this but are just naturally curious about your environment and found a quirk that you can't explain and (even though it never needs to be used letalone explained) you want to know the answer to it. Think about it, what other attributes might these tables have?

(Hint: It's cellpadding and cellspacing)

So I hope that answers your question and do yourself a favor and learn some CSS, if you haven't already.
 
Back
Top