Why the need for a <span> tag inside another tag?

I am completing the Build Your Own Cheat Sheet exercise, though my question is more general. In the HTML for the example solution, several table data cells include the following code:

<td><span class="code">&lt;table&gt;</span></td>

It seems to me the element is redundant, and the line could be written as:

<td class="code">&lt;table&gt;</td>

Am I right, or is there something I don’t understand? Thank you.

:slight_smile:

1 Like

It could be redundant, but if you’re applying a lot of CSS to both the span and td elements, it might be easier to read…


Also, <span> tags in general help you to apply special formatting to smaller pieces of text/information within a larger element.

1 Like