I have a component that create dynamically html table. According to my need, I need to show td tags line by line as a block element not like column. How to do that by using CSS ?
You cannot put tr inside td. You can see the allowed content from MDN web docs documentation about td . The relevant information is in the permitted content section. Another way to achieve this is by using colspan and rowspan .
An HTML table consists of one <table> element and one or more <tr>, <th>, and <td> elements. The <tr> element defines a table row, the <th> element defines a table header, and the <td> element defines a table cell. An HTML table may also include <caption>, <colgroup>, <thead>, <tfoot>, and <tbody> elements.
The <td> tag defines the standard cells in the table which are displayed as normal-weight, left-aligned text. The <tr> tag defines the table rows. There must be at least one row in the table. The <th> tag defines the header cells in the table which are displayed as bold, center-aligned text.
You can't have tr as direct children of a div .
Try this:
td{
display: table-row
}
You can do this by applying display: block
to the td
s:
http://jsfiddle.net/wYA9K/
That works in all modern browsers except IE9..
Using float: left; width: 100%
instead makes it also work in IE8/9:
http://jsfiddle.net/gvpzh/
Nothing will make it work in IE7.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With