0

HTML5 has some useful semantic tags for use. They're not actually necessary, but the point of 'Semantic Web' can be helpful for organizing a lot of content.

I just came across a simple <small> tag which I never saw before. It works as it sounds, the text gets smaller.

What if the !DOCTYPE html was not for HTML5 but other legacy doctypes, what are good alternatives besides simply doing following style/CSS adjustments?

CSS: p {font-size: smaller}

HTML attribute: <p style="font-size: ##%">This text.</p>

1
  • 2
    Note that "text in small font" is presentational, not semantic meaning. The current semantic meaning of <small> in HTML5 is "small print" as in legal text or sidenotes. Commented Oct 21, 2017 at 7:34

3 Answers 3

2

What if the !DOCTYPE html was not for HTML5 but other legacy doctypes

<small> was introduced in HTML 3.2, not in HTML 5, so you should still use the <small> element.

The semantic meaning that <small> holds in HTML 5 wasn't there in earlier versions of HTML, but there was nothing with equivalent semantics that would be better.

Sign up to request clarification or add additional context in comments.

Comments

1

An alternative would be to use a class name such as .small-text to represent small text.

.small-text {
    font-size: smaller;
}

However, you should also ask yourself whether defining a class for small text is necessary. For example, you might actually want this instead:

.subtitle {
    font-size: smaller;
    /* other styles */
}

and avoid creating too many useless class names.

Comments

0

Thanks for the answers people...

I believe the <span> tag is an excellent alternative for the similar results. The difference would be that the tag comes with a preset size. <span> brings a different value being unchanged until inheriting via css/attr or js.

You won't necessarily have to worry about adding a new class, you can have it inherit a style by relative placement.

ie. <article><p>Text here to continue for who knows how long.<small>This is small text.</small></p></article>

<article><p>Text here to continue for who knows how long.<span>This is small text.</span></p></article>

The advantage is <small> </small> will already be smaller, but who knows at what default size?...

The <span></span> will just be there awaiting definition to it...

CSS: article > span { font-size: ###;} //no class necessary unless you really want varying span sizes in the content paragraph.

1 Comment

from my experience I would say that the example you give will many times lead to surprises when you later create another span in that article for different reasons where the smaller text is not desired. ofc it depends on many factors what is the best middle ground between too general and too specific css..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.