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).
Note that the “Out of Town” td element spans both the “Monday” and “Tuesday” columns, for a total colspan of 2.
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?
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.
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’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.
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.
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:
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.