Jump to content

newbie Q re table, col width

Recommended Posts

Hi Friends,

This will probably be easy for you.  I'm trying to learn some simple info about tables, and I'm studying this page https://www.w3schools.com/html/html_tables.asp and specifically this example https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_intro

I see that the first column is wider than the other 2.  But I can't figure out which code on the left side of the page is responsible for that.

When I remove the width = 100% part, it removes all the extra space.  So that partly answers it.  But why does the first column have more extra space than the other 2 columns?


Thanks for your help.

Link to post
Share on other sites

By default, the browser decides how much space to reserve for the columns based on how much content is in each one. I'm not sure if the W3C specifies an algorithm for this or if each browser just does its own thing.

You can manually set the width of a column by setting the width of one of its cells, however a cell will always be forced to be wide enough to fit its content without overflowing.

Link to post
Share on other sites

Thanks for the info!

Yes, I remember that there's a way to set the column width. But I can't find a page on w3schools.com that explains it. Could someone either show me the page, or show me the proper code?


I found some old pages of mine that show row span and col span. But I can't find one for column width.

Edit #2
I need inline code. I can't get to the stylesheet or style tags. So it needs to be inline code. I looked and looked on w3schools.com. Can't find.

Edited by brynn
Link to post
Share on other sites

Yes, that code should work. You can set the width of anything on the page using CSS. The code above is just CSS inside an HTML attribute.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...