Packy
Packy

Reputation: 3573

sup tag doesnt work inside title tag

I have a sup tag in a title tag and it does not work but will work in a li tag. Anyone know why? I can change the title tags out to H class but its bugging me to know. Here is what I have:

<ul>
  <title>TPC <sup>®</sup></title>
  <li>TPC<sup>®</sup></li>
  <li>TPC<sup>®</sup></li>
  <li>TPC<sup>®</sup></li>

</ul>

The sup works fine in all the li tags but not the title. In the title it displays the actual code as text.

Upvotes: 0

Views: 2566

Answers (3)

Rick Hitchcock
Rick Hitchcock

Reputation: 35670

The title element is used only to set the title of the document, which you'll generally see in the browser's tab.

Only li elements are allowed as direct children of the ul element.

If you're hoping to style the page's title, you're out of luck. Only text can be used within the title element.


If you'd simply like to style the first item in a list differently, you can do something like this:

li:first-of-type {
  color: red;
}
<ul>
  <li>TPC<sup>®</sup></li>
  <li>TPC<sup>®</sup></li>
  <li>TPC<sup>®</sup></li>
  <li>TPC<sup>®</sup></li>
</ul>

Upvotes: 4

m4n0
m4n0

Reputation: 32255

Title tag is used within <head></head> not within <body></body>

Upvotes: 1

elixenide
elixenide

Reputation: 44823

You can't (okay, technically shouldn't) use title tags anywhere other than in the head tag, and there should only be one title tag in a document. A ul tag definitely cannot have a title tag as a direct child; only an li tag is appropriate there.

So, the short answer to your question is: don't do this. It's not supposed to work, so it probably won't.

You can read more here.

Upvotes: 1

Related Questions