4
<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?

Ethyl Casin
  • 791
  • 2
  • 16
  • 34

2 Answers2

3

The 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.

Community
  • 1
  • 1
Fabian Streitel
  • 2,702
  • 26
  • 36
3

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 image on nodeType

w3schools on nodeType

kemicofa ghost
  • 16,349
  • 8
  • 82
  • 131