Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blank HTML tags

Tags:

html

css

tags

Is there a way to have blank HTML tags or in other words, tags that do nothing? For example <p> turns the inclosed text into a paragraph, <b> turns the text bold, <div> creates a box. I'm looking for a tag that has no effect on the text or it's environment. I want this so that I can customise it myself with css or js.

I am <x class="FancyText">king</x> of the world.
like image 509
Makai Avatar asked Jul 22 '26 04:07

Makai


2 Answers

There are no “blank HTML tags”. What come closest are span and div, but the latter causes line breaks before and after (block rendering) by default and cannot be used in inline context, and the former does not allow any block-level elements inside it.

In practice, you can use a made-up element, like <foo>...</foo>, though with some problems on older versions of IE. This is widely regarded as a bad move, though; using span or div, as appropriate, with a class attribute is recommeded.

Consider explaining what you are really trying to achieve, instead of referring to fictional HTML tags expected to do nothing.

like image 69
Jukka K. Korpela Avatar answered Jul 23 '26 19:07

Jukka K. Korpela


For this you'd use either the div or span element. From the HTML5 editor's draft:

The div element has no special meaning at all. It represents its children.

The span element doesn't mean anything on its own. ... It represents its children.

The difference between them is that the div element should be used where flow content is expected (that is to say, sections on a page), whereas the span element should be used where phrasing content is expected (within text).

In the example you've given, you'd want to use the span element:

I am <span class="FancyText">king</span> of the world.
like image 34
James Donnelly Avatar answered Jul 23 '26 18:07

James Donnelly