Proposal for <text> tag


#1

Hello Everyone,

HTML5 currently has a lot of tags which are for text markup like abbr, address, b, bdi, bdo, blockquote, caption, cite, h1 to h6, ins, label, p, pre, q, s, small, strong, sub, sup, etc. Each of them contributes to their own significance in the markup. None of them for a general text markup which can be used for some miscellaneous purpose like username in the sidebar. It can’t be treated as a heading, nor a p and neither as a span (which is used for styling a part of the text in a section).

For this, I propose a plain and general text tag named text. It will be a tag which can be used for any text which can’t be fitted in any above-mentioned tags. For example, now if I want to create a plain text markup for username, I’d simply create, Ishaan Rawat It would be an inline tag and would not format the text in any way just like many other tags, instead will make it more readable in the markup. The for attribute can be used to tell the purpose of the tag (which may be used for accessibility purpose also)

Now, I see this as a new way to style text of similar kinds like, text[for=“username”] { font-weight: bold; font-size: 2em; }

Let me know if this sounds good or not.


#2

You only mentioned one use-case, a username in a sidebar? I think differentiating names from words on the web could be helpful for people using screen-readers. There was a similar proposal for the <author> element.

About the text-selector argument, there is already a proposal for a text-node selector at CSSWG.


#3

I gave the first example that came to my mind. I was thinking of many other text that we want to style which don’t come under any general heading or paragraph markup. There have been times when I wanted to style a particular text but had to use div, headings or paragraphs in those cases. I was thinking of a general tag which don’t spoil the markup by using irrelevant tags. :slight_smile:


#4

I worry about the performance implications of exposing all text nodes via selectors. As an anecdotal example, the number of Text nodes in Twitter’s DOM hovers near 2x the number of Elements. Around 1/3 of those are whitepsace-only nodes.

A separate <text> node might be interesting.


#5

<span> is the best node for this right now. I’m not sure why we need to introduce something new for this. Span is the literal original generic text node.