admin管理员组文章数量:1430562
<table>
<tr>
<td>Hello StackOverFlow</td>
</tr>
</table>
Hi! I am new to html, can someone tell me what type of element is the word 'Hello StackOverFlow' inside the td tag? Is it a label?
<table>
<tr>
<td>Hello StackOverFlow</td>
</tr>
</table>
Hi! I am new to html, can someone tell me what type of element is the word 'Hello StackOverFlow' inside the td tag? Is it a label?
Share Improve this question asked Apr 21, 2015 at 7:32 Ethyl CasinEthyl Casin 7932 gold badges17 silver badges34 bronze badges 9- 11 It is a text node. – Sami Kuhmonen Commented Apr 21, 2015 at 7:32
-
What he said. However, if you're referring to the
<td>
then that is a table data (I usually refer to it as a cell) . – Adam Kewley Commented Apr 21, 2015 at 7:33 - it refers to table data (td) – Aru Commented Apr 21, 2015 at 7:33
-
1
For styling with CSS:
td { background-color: #000; }
, unless you need something more specific – Adam Kewley Commented Apr 21, 2015 at 7:34 -
1
If you want to change the textnode within a
td
then all the manipulations are done with the parenttd
. For example:td { font-size: 2 em; }
– Adam Kewley Commented Apr 21, 2015 at 7:36
2 Answers
Reset to default 3The element inside the <td>
tag is a text node. You can't address it in CSS. If you want to style it, you either have to style the <td>
tag or surround the text you want to style with a <span>
element.
So to, e.g., style only the Hello
:
<table>
<tr>
<td><span>Hello<span> StackOverFlow</td>
</tr>
</table>
And in your CSS
span { font-weight: bold; }
Or whatever style you want to give it.
See also the answer to this related question.
Want to check the type of Hello Stackoverflow? Simpy check the td's content's nodeType
//Gave your td an id of 'td'
alert($('#td').contents().get(0).nodeType);
This will return 3. A nodeType of 3 means it is a text.
Here is an image of each nodeType:
w3schools on nodeType
本文标签: javascriptelement inside td tagStack Overflow
版权声明:本文标题:javascript - element inside td tag - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745558696a2663341.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论