HTML 'td' Width And Height - Stack Overflow

Just browsing Stack Overflow? Help us improve your experience. Sign up for research
    1. Home
    2. Questions
    3. Tags
    4. Users
    5. Companies
    6. Labs
    7. Jobs
    8. Discussions
    9. Collectives
    10. Communities for your favorite technologies. Explore all Collectives

  1. Teams

    Ask questions, find answers and collaborate at work with Stack Overflow for Teams.

    Try Teams for free Explore Teams
  2. Teams
  3. Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Get early access and see previews of new features.

Learn more about Labs HTML 'td' width and height Ask Question Asked 12 years, 1 month ago Modified 7 years, 1 month ago Viewed 353k times 61

The 'height' and 'width' are not supported in HTML5. How can I set a td's width and height while conforming to the HTML5 standard?

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>219 班網</title> </head> <body bgcolor="silver"> <div align="center"> <table> <tr> <td width="1000" height="250"> <object width="100%" height="100%" data="frameTop.html"></object> </td> </tr> </table> <table> <tr> <td width="300" height="700" > <object width="100%" height="100%" data="frameLeft.html"></object> </td> <td width="700" height="700"> <object width="100%" height="100%" data="frameRight.html"></object> </td> </tr> </table> </div> </body> </html> Share Improve this question Follow edited Oct 25, 2016 at 14:52 Brian Tompsett - 汤莱恩's user avatar Brian Tompsett - 汤莱恩 5,87572 gold badges60 silver badges133 bronze badges asked Oct 14, 2012 at 9:50 Shane Hsu's user avatar Shane HsuShane Hsu 8,3076 gold badges42 silver badges65 bronze badges 3
  • To any HTML/javascript people that the code is in C-style layout LOL – Shane Hsu Commented Oct 14, 2012 at 9:51
  • @Zyga So if I use CSS to assign width and height value, it won't be in conflict with HTNL5 standard? – Shane Hsu Commented Oct 14, 2012 at 9:53
  • Thats right, there is no conflict as its CSS code not HTML. The HTML attributes were deprecated in HTML5, nothing to do with CSS if you know what I mean. – Zyga Commented Oct 14, 2012 at 9:56
Add a comment |

2 Answers 2

Sorted by: Reset to default Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 98

The width attribute of <td> is deprecated in HTML 5.

Use CSS. e.g.

<td style="width:100px">

in detail, like this:

<table > <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td style="width:70%">January</td> <td style="width:30%">$100</td> </tr> <tr> <td>February</td> <td>$80</td> </tr> </table> Share Improve this answer Follow edited Jun 6, 2014 at 0:51 bd33's user avatar bd33 5121 gold badge15 silver badges31 bronze badges answered Oct 14, 2012 at 9:54 Ravindra Bagale's user avatar Ravindra BagaleRavindra Bagale 17.6k9 gold badges45 silver badges70 bronze badges 5
  • What if you need to exceed the width of the page? For example the width of the page is 2000 and your cell needs to be 5000 like: <td style="width:5000px">January</td> – Igor Krupitsky Commented Feb 9, 2016 at 9:46
  • @IgorKrupitsky put the table inside t div that has css: overflow-x: scroll; You will then get a horizontal scrollbar – punkologist Commented Jul 12, 2016 at 4:34
  • 7 doesn't seem to work for a table with more columns, and where the columns have varying amounts of data in them – Don Cheadle Commented Sep 12, 2016 at 19:25
  • 1 "The width attribute of <td> is deprecated in HTML 5." - it was actually already deprecated in HTML 4; see w3.org/TR/html401/struct/tables.html#edef-TH. – Mark Amery Commented Jul 22, 2017 at 16:25
  • 1 Its deprecated but I noticed it still working - at least in Chrome 64. Why? – ed1nh0 Commented Feb 26, 2018 at 12:53
Add a comment | 17

Following width worked well in HTML5: -

<table > <tr> <th style="min-width:120px">Month</th> <th style="min-width:60px">Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$80</td> </tr> </table>

Please note that

  • TD tag is without CSS style.
Share Improve this answer Follow edited Oct 16, 2017 at 18:58 answered Oct 16, 2017 at 18:44 Sukumar's user avatar SukumarSukumar 3293 silver badges10 bronze badges 0 Add a comment |

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid …

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Draft saved Draft discarded

Sign up or log in

Sign up using Google Sign up using Email and Password Submit

Post as a guest

Name Email

Required, but never shown

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.

  • The Overflow Blog
  • Your docs are your infrastructure
  • Featured on Meta
  • More network sites to see advertising test [updated with phase 2]
  • We’re (finally!) going to the cloud!

Linked

652 How to set up fixed width for <td>? 0 JQuery - Every click on table changes the cell width 1 HTML TD width not taking effect 0 Why two tables cannot align properly? 1 Resize TD in a table 0 how to set width,height etc to particular table in html 0 HTML - table / td sizing issue 0 Change size of TD in an HTML table 0 Width property applied to td 0 td height and width not getting picked up 1 increase width and height of td cells in html 1 How to set Dynamic height and width to a HTML table? 0 Table dimensions in CSS not working in HTML 0 JavaScript, td size always change

Hot Network Questions

  • Does length contraction "break the speed limit"?
  • Why did Satan take Jesus to the Temple to jump down from?
  • Mega Man: Powered Up
  • Diagonal analogue of symmetric functions
  • What exactly is the cornerstone that Mark 12:10 speaks of?
  • What mechanism could cause a person not to cast a reflection?
  • I am the owner of an image. I published it in Unsplash. Am I allowed to upload that same image to other sites?
  • The product of the alternating lengths of a hexagon whose vertices belong to an ellipse
  • Values of quadratic function and its discriminant
  • Is ATL-98 Carvair still alive in the US?
  • What's a good way to append a nonce to ciphertext in Python for AES GCM in Python?
  • Walks in Nice (Nizza)
  • What was the female equivalent of πάππας in Ancient Greek?
  • Isekai mahwa with silver haired male lead who is an illegitimate prince
  • What powers do police have to force people onto trains?
  • Can you see through a cannonball packing?
  • How is one supposed to play these notes?
  • Reality check: energy source for power armour
  • Can .zshrc be modified automatically?
  • Conditional Definition of a Mathematical Operator
  • If Occam's razor supports naturalism over theism, then why was William of Ockham, its author, a theist and not a naturalist?
  • p column type stops compilation in RevTeX
  • Find the one sentence that is wrong in the following proof.
  • Is there a limit below a panel's rating for bonding neutrals and grounds?
more hot questions Question feed Subscribe to RSS Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

lang-html

Từ khóa » Html Td Width Html5