What should colspan="2" look like?

Question

What should the example for colspan=“2” in this exercise look like? What does a td element look like when it spans multiple columns?

Answer

Here is what the html will look like on the page (with a little extra css added to make the sections clearer).
17%20AM
Note that the “Out of Town” td element spans both the “Monday” and “Tuesday” columns, for a total colspan of 2.

18 Likes

Which attribute allows me to span two cells in different rows?

5 Likes

I think it’s rowspan=“number”.

6 Likes

rowspan=“2” цифра означает сколько ячеек нужно обьеденить

4 Likes

Can I achieve the same result using css { padding:…px} instead?

1 Like

Different question, but related to topic: when I span the table data element over two columns, it overwrites what was already in that location since I have done it over 2 columns. I this what it should be doing? The system gave me a green check. It also moved the word ship as the only text that is in the not yet in existence 4th column. It seems there is something wrong?

2 Likes

When, You assign colspan=“2”,you can apply it on

or a/c to your need.
And it enlarges the current cell over 2 consecutive columns, And the Other Cell present on rt side to it will be Shifted by one cell to the right.
1 Like

Hello everyone
Can I ask? Why when I give the element of my table the atribute scope=“row” and than complete it with the atribute colspan=“2”. Why it’s not work?

On the code it looks like the next:
Miss Sally’s Southern
4
Ship

Do you mean that your row is a column ?
It would be best if you gave the complete info and code so we can understand better what you mean. (I’m on this lesson and interested by your question).
Have a good day and take care !

I commented out the last column item when I did this exercise. I used the middle column and commented out the 3rd. < !- - . . . - - >

1 Like

I commented out the last column item when I did this exercise. I used the middle column and commented out the 3rd. < !- - . . . - - >

For me, my row became a column when I did rowspan=“2”

I’m unsure, but it seems to me that this is more of a structural change, so it should be made with HTML as HTML is responsible for composing the structure of our document as opposed to CSS, which is responsible for the appearance/presentation of our document.

why do I have to use use >colspan cause it’s not making much of a difrence is it?

Its used to span columns with same data. So instead of writing a data twice, you can just write colspan=“2” to do the same work. Moreover in daily life, we sometimes need to write same data for more than one column like the exercise. Hence, it definitely makes a difference. I know its late and you must’ve finished the lesson already .Still I hope it helps you somehow.

Hey guys. I just completed the assignment 7/13 in HTML Tables about spanning Columns, where I had to use the “colspan” attribute, to span 1 datapoint across 2 columns, but the formatting looks off on the table itself since there are only 3 colums, but 4 datapoints when spanning 1 across 2, so I had to delete 1 datapoint to make everything fit. I just wanted to know if there’s any other way to do it, since it says “Your formatting looks a bit off” in the “hint” box below, but obviously I still did what it wanted me to do.

Thanks

1 Like

You are using it on a table header and not on table data

Thank you. This is really useful.

Certainly! The HTML code <td colspan="2">Out of Town</td> is used to create a table cell that spans two columns and displays the text “Out of Town” in that cell. Here’s an example of how you can use this code in an HTML table:

<table border="1">
  <tr>
    <td>City</td>
    <td>State</td>
  </tr>
  <tr>
    <td colspan="2">Out of Town</td>
  </tr>
</table>

In this example, we have a simple HTML table with two rows. The first row contains two regular table cells (<td> ) for “City” and “State.” The second row contains a single table cell with colspan="2" , which spans both columns and displays “Out of Town.” This is useful when you want to merge cells across multiple columns in a table.

1 Like