# Question about HTML/CSS Coding

**URL:** <https://boards.straightdope.com/t/question-about-html-css-coding/942379>\
**Category:** Factual Questions\
**Created:** [May 18, 2021, 4:49pm UTC](https://boards.straightdope.com/t/question-about-html-css-coding/942379 "2021-05-18T16:49:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bookkeeper](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bookkeeper/32/281_2.png) [@Bookkeeper](https://boards.straightdope.com/u/Bookkeeper)\
**Post date:** [May 18, 2021, 4:49pm UTC](https://boards.straightdope.com/t/question-about-html-css-coding/942379/1 "2021-05-18T16:49:58Z")

</div>

I have a website that uses a lot of tables. Most, but not all, need borders on the table and table cells for readability. I have been using the following code to do this:

The border=1 element places both external and internal borders in the table, but is obsolete for HTML 5 and should not be used. I can use CSS codes to place borders, but must use separate codes for the table and the individual TD elements.

How can I code for internal cell borders in a simple to code way that does not require adding style codes to every TD element, or putting them in my .CSS file, which would place borders on all TD elements, even those I don’t want bordered? Bonus if the fix is easily applicable to the around 100 web pages using tables.

---

<div class="post-metadata">

**Author:** ![Manduck](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/manduck/32/256_2.png) [@Manduck](https://boards.straightdope.com/u/Manduck)\
**Post date:** [May 18, 2021, 5:08pm UTC](https://boards.straightdope.com/t/question-about-html-css-coding/942379/2 "2021-05-18T17:08:48Z")

</div>

Give a class to the table, so that you can write a CSS rule that only applies to child TDs of that class:

\<table class=“myclass”\> etc

.myclass TD {border: 1px solid black;}

---

<div class="post-metadata">

**Author:** ![Manduck](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/manduck/32/256_2.png) [@Manduck](https://boards.straightdope.com/u/Manduck)\
**Post date:** [May 18, 2021, 5:14pm UTC](https://boards.straightdope.com/t/question-about-html-css-coding/942379/3 "2021-05-18T17:14:15Z")

</div>

You’ll probably also want to collapse borders

.myclass {border-collapse: collapse;}

---

<div class="post-metadata">

**Author:** ![Bookkeeper](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bookkeeper/32/281_2.png) [@Bookkeeper](https://boards.straightdope.com/u/Bookkeeper)\
**Post date:** [May 19, 2021, 4:11am UTC](https://boards.straightdope.com/t/question-about-html-css-coding/942379/4 "2021-05-19T04:11:29Z")

</div>

Thanks. I’ll try this suggestion.
