DEV Community

[Comment from a deleted post]
Collapse
 
jaguart profile image
Jeff • Edited

It's good to publish your recommendations on improving HTML - thank you :-)

There is one thing I disagree with though - and that is the use of <span></span> for text - as I don't think that this has a proper semantic meaning.

In my opinion, you should use <p>A complete block of text, also known as a sentence.</p> as the paragraph-tag has semantic meaning for text. The main issue is that many webdevs hate the default browser spacing around paragraphs. (hint: use CSS!)

For me, <span></span> is for a text fragment in some unusual non-semantic context. For example: <p>I was walking down the hill, and my feet hit a <span style='position:relative;top:-0.2em'>bump</span> that caused me to stumble.</p>. In this example, the complete sentence is enclosed in paragraph-tags showing that it make a semantic whole, and the span-tag is just used for visual effect (no semantic meaning).

One of the historic issues with HTML is the over-focus on appearance, and the low priority given to semantics.

Just my $0.02 - thank you for the article, it is good to improve the world's HTML :-)

Collapse
 
melnik909 profile image
Stas Melnikov

A text fragment hasn't limits on words. Thus we can use the span for any text. The p is paragraph. The problem is we don't have single opinion what a paragraph is. I think a paragraph is sequence of text blocks that are united by one meaning.

Collapse
 
jaguart profile image
Jeff

I mostly agree with you.

I think there is an even higher zeroth law for HTML goodness, which is something like:

Always use accurate SEMANTIC HTML wherever possible

This article explains it better than I can: w3schools.com/html/html5_semantic_...

When we do our HTML code reviews, we count the non-semantic tags like <span> - they are are considered a code-smell - that indicates something might be going wrong...

Semantic-HTML is good for the soul. Namaste.

 
melnik909 profile image
Stas Melnikov

The span is the same semantic element like other

 
jaguart profile image
Jeff • Edited

No its not :-)

Check the w3schools intro to semantics - right at the top, around the 3rd line...

Examples of non-semantic elements: <div> and <span> - Tells nothing about its content.

is a non-semantic element.

 
melnik909 profile image
Stas Melnikov

The fact that you say the span isn't semantic element is the span is semantic element because if it don't have semantic (meaning) you can't do it. And just read specs