Solved

Simplest approach to making a border for a table in CSS via CSS Class....

Posted on 2011-09-13
5
229 Views
Last Modified: 2012-05-12
Hi,

My brain is not working today!!!

I need to specify a simple rule in a class to make all of a table have a 1px border for all of its cells be they THs or TDs.

Also I noticed when I used "border-left" I got the border only where there was text so if I have 2 columns, one with 2 rows worth of text(wrapped around), the one is only one row produced half a "border-left" border if you get me.

So what is the simplest CSS method to specify a border throughout a table?

Thanks,

Sam

0
Comment
Question by:SamJolly
5 Comments
 
LVL 38

Assisted Solution

by:Tom Beck
Tom Beck earned 150 total points
ID: 36528795
table, th, td {border:solid 1px black}
0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 150 total points
ID: 36528797
#table1 tbody tr td, #table1 tbody tr th
{
   border: 1px solid #000;
}

or

td, th
{
   border: 1px solid #000;
}


simplest way is
<table border="1">

check this too
http://www.ahfb2000.com/webmaster_help_desk/showthread.php?t=1790
0
 
LVL 22

Accepted Solution

by:
Kim Walker earned 200 total points
ID: 36528867
Some browsers will not put borders around empty cells so you must put at least an &nbsp; character in each cell. If you also want to eliminate the double border between cells, you can use the border-collapse property. The border-collapse property also takes care of the empty cells in most cases.

table { border-collapse: collapse; }

Open in new window

0
 

Author Comment

by:SamJolly
ID: 36528953
xmediaman: you little tit bit about border-collapse came just in time ! Thanks....
0
 

Author Closing Comment

by:SamJolly
ID: 36992052
thks all.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question