开发者

CSS: can css applied to <td> and <tr> elements perfectly simulate the style of <div> elements?

开发者 https://www.devze.com 2023-01-06 05:36 出处:网络
I wanted to know if I customize a table with <td> and <tr> elements in the same way I usually customize <div> elements of a page.

I wanted to know if I customize a table with <td> and <tr> elements in the same way I usually customize <div> elements of a page.

I开发者_StackOverflow中文版'm asking this because I cannot modify the generated html code, and I would like for example to float the rows to right, or to add padding, margin.

Is CSS working perfectly on <tr> or <td> elements ? (I am asking you this before to start).

thanks


Is CSS working perfectly on or elements ? (I am asking you this before to start).

Yes, you can apply css to any element. By the way, you can choose the direction of TDs by specifying align="left" or align="right". No need to float them. You could have provided sample of what you want to achieve though.


It all depends what you want to do. If you want to apply custom floating to particular cells (using CSS float) you might get crazy results because you mock around with box-model of <td> element.

If you want to float the text/content inside, you can always use text-align:left / right / center.

Again - if you want to affect content of the TD it should be relatively same as if you used <div>. If you want to affect td itself you might get unexpected results especially around position, float, z-index, display CSS attributes.


"I am asking you this before to start".

That's a bit stupid (no(t too much) offense) don't you think?

If you had give it a try you would have seen that there's no problem. Just be aware that default style is not the same and that there are some constraint due to the displaying of table element (which you can get rid of by using the css display property).

0

精彩评论

暂无评论...
验证码 换一张
取 消