1000Gbps 1000Gbps - 8 months ago 37
CSS Question

Table borders not drawn in HTML4+

I got another problem, this time with tables and their borders in HTML (4.01, 5.0)

Notice: All codes are from w3schools.com

When using this code:

<h4>One row and three columns:</h4>
<table border="1">

Everything is drawn correctly in the browser (FF, IE, Opera, Chrome), but when the
is changed with
style="border: 1px;"
the borders and cell walls disappear.
I can't find the reason, but using
gives me the precious validation.

That's my main file sections:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
Title of the document
<style type="text/css">
body {background-color:teal;}

I hope someone here knows where's the problem is ...
Here are the results with classic

http://www.free imagehosting.net/pyk3e << border="1"

http://www.free imagehosting.net/cw98o << style="border: 1px solid black;" for cells too

Answer Source

You may need border: 1px solid;. Having the pixels alone isn't enough, you have to tell the browser what to do with them. :)

But remember that if you use <table style="border: 1px solid">, that will create a border around the TABLE, not the cells within the table.

You'll need to specify a border for the cells too.

You should probably just specify a stylesheet:

<style type="text/css">
    border: 1px solid;

Or even, identify your table or TD blocks with an ID or a class, then use that in your stylesheet, so you don't affect other innocent bystander tables.