Solved

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

Posted on 2011-09-13
5
226 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 21

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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 …

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now