Solved

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

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

724 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