Hello,

I am trying to place border colors around the whole table including inside the tables. Yet, what happen is the border only appears outside the table like a box. There are no borders inside the table. How to place borders including inside the tables?

image_gallery.php

<!-- border="1" -->
                <table style="margin: 50px 0 0 -150px; position: relative;" id="admintable"  cellpadding="2" cellspacing="0">

main.css

table{
border: 1px solid #e2e0e0;
}   

Recommended Answers

All 4 Replies

just go with

#admin {
    border: 1px solid #f6f6f6;
}

Seeing as you have already specified an ID you don't need to include the table selector. It means the CSS is trying to style a table that is a child of #admin

I think you may want to style the <td> borders instead of the <table> borders to get what you're looking for. So:

table#adminTable
td {
    border: 1px solid #e2e0e0;
}

Hello below css code will give the border to the table

table {
    table-collspace:collspace;
    border:1px solid #e2e0e0;
}

if you want to give borders to td you can do the following

table td {
    border:1px solid #e2e0e0;
}

Hope this will help you out

Member Avatar for diafol

If you have a semantic table: <tbody> with <td> and <thead> with <th> - don't forget to include the th in your css.

Example:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
#admin{
    border-collapse:collapse;
}
#admin th, #admin td{
    border: 1px #e2e0e0 solid;
}
</style>
</head>

<body>

<table id="admin">
    <thead>
        <tr>
            <th>Heading One</th>
            <th>Heading Two</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Data content one</td>
            <td>Data content two</td>
        </tr>
    </tbody>
</table>
</body>
</html>

You could even do this:

#admin *{
    border: 1px blue solid;
}

But that's horrible. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.