Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-09-13
5
Medium Priority
?
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 38

Assisted Solution

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

Assisted Solution

by:Gurvinder Pal Singh
Gurvinder Pal Singh earned 600 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 800 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

650 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