Reputation: 146
I have the following line of code in my html page & table doesn't show up borders
<table style="{border-color: black;padding-left:2px;border-style: solid;border: 5px;border-width: 2px; }">
Can you help me debug that.
Upvotes: 2
Views: 1312
Reputation: 1031
Try this:
Your Code:
<table id="table" style="border-color: black;padding-left:2px;border-style: solid;border: 5px solid black;">
Upvotes: 0
Reputation: 201588
There are several issues involved:
{
and }
make the code invalid and cause it to be skipped. Remove them. Reference: CSS Style Attributes.border
notation always sets all border properties, using initial values as defaults. Thus, border: 5px
sets border-style
to none
(and border-color
to the value of the color
property). The simplest fix is to remove that declaration; it seems to be meant to set border width, but used this way it has undesired side effects, and besides you are setting the width in later declaration (to a different value).style
attribute of the table
element; you need to set them in style
attributes of cell elements or (better) in a style
element or (even better) in a linked style sheet.The minimally fixed code that deals with the first two issues is:
<table style="border-color: black;padding-left:2px;border-style: solid;
border-width: 2px">
Upvotes: 0
Reputation: 567
In addition to the unnecessary braces, the border CSS needs a little love. Try this instead:
<table style="padding-left:2px; border: 5px solid black;">
Upvotes: 2
Reputation: 13978
Syntax error. Remove {
and }
<table style="border-color: black;padding-left:2px;border-style: solid;border: 5px;border-width: 2px;">
Also no need to write border-color
, border-style
and border-width
separately. You can combine and simplify like below.
border:2px solid black;
So you can update your code like this.
<table style="border:2px solid black; padding-left:2px;">
Upvotes: 2