Line25

You’re Doing it Wrong: Common HTML Tag Misuses

You’re Doing it Wrong: Common HTML Tag Misuses
Home » Articles » You’re Doing it Wrong: Common HTML Tag Misuses

Line25 is reader supported. At no cost to you a commission from sponsors may be earned when a purchase is made via links on the site. Learn more

View the source code of a hand full of websites featured in CSS galleries today and you’ll often see the same errors appear time and time again. These mistakes are usually habits we picked up during our early days of coding that have stuck around due to lack of clarification. This post rounds up a collection of common HTML tag and element misuses and describes the best practice to correctly and semantically use them in your markup.

Misuse of the <br> tag

The <br> HTML tagPin

How not to use the <br> tag

A common misuse of the <br> tag is to use it to create spaces or gaps in your content. WYSIWYG editors are notorious for injecting multiple line breaks or empty paragraph tags.

How to properly use the <br> tag

The <br> is used to insert a line break in a sentence. Examples might be to correctly lay out an address. Use paragraph elements to split up your content and use CSS margins to alter the spacing between them.

Misuse of the <div> tag

The <div> HTML tagPin

How not to use the <div> tag

When we first get to grips with HTML and coding in CSS we often get carried away with our divs and surround almost every page item with its own div tags.

How to properly use the <div> tag

The <div> tag is perfectly acceptable to use to define the main page structure, but always try to use more suitable tags for your page elements. Paragraph tags, ordered/unordered lists and definition lists can be more semantic choices.

Misuse of the <small> tag

The <small> HTML tagPin

How not to use the <small> tag

The <small> tag is often wrongly used as its name suggests, to create text that’s small in size.

How to properly use the <small> tag

CSS should always be used for presentational styling, so use the font-size CSS property to control your text sizes. The <small> HTML tag is reserved for defining “smallprint” or legal text.

Misuse of the <hr> tag

The <hr> HTML tagPin

How not to use the <hr> tag

The use of the <hr> is pretty rare these days, but when you do see it you can guarantee it’s being misused as a presentational line between sections of a page.

How to properly use the <hr> tag

These days the CSS border property is the correct solution in most situations, however the <hr> tags still has its use in specific situations when defining layouts containing copy such as book chapters or poetry stanzas.

Misuse of the <title> tag

The <title> HTML tagPin

How not to use the <title> tag

In most cases the HTML <title> tag (not the attribute) is misused in two extremes. It either contains no valuable information, or it’s packed full of endless keywords for “SEO”.

How to properly use the <title> tag

The <title> should accurately but concisely describe the contents of the page. It’s important to include keywords that relate to the content as it is recognised by search engines, but it shouldn’t be abused.

Misuse of the <img> tag

The <img> HTML tagPin

How not to use the <img> tag

The misuse of the <img> is actually more to do with the misuse of its alt attribute. Often the text within the alt attribute is completely irrelevant (if it exists at all!).

How to properly use the <img> tag

<img> tag alt attributes should contain an accurate description of the image. If the image is being used as a link give an insight to where the link will go. If the image has no importance an empty alt attribute is acceptable.

Misuse of the <label> tag

The <label> HTML tagPin

How not to use the <label> tag

<label> is another tag that is often left out altogether rather than being misused. When it does appear it rarely includes the for attribute.

How to properly use the <label> tag

Use the <label> tag to relate a field to its descriptive label. For extra usability points add the for attribute to allow the user to click the label to activate the relevant input field.

Misuse of the <address> tag

The <address> HTML tagPin

How not to use the <address> tag

The name of the <address> wrongly suggests that it should be used to surround a postal address on a contact page.

How to properly use the <address> tag

The correct use of the <address> tag is to define the author or owner of the document. Therefore it’s usually wrapped around their name along with their contact email address or telephone number.

Written by Iggy

Iggy is a designer who loves experimenting with new web design techniques, collating creative website designs, and writing about the latest design trends, inspiration, design freebies, and more. You can follow him on Twitter

59 Comments

Would you like to say something?

  1. Jacques says:

    Really cool article ;) First time I read an article on this topic.

    I was still doing few of these common HTML tag and element misuses… I will try to correct my practice now.

    Big thanks ;)

  2. Thierry Ouellet says:

    Thanks for refreshing my memory regarding the label tag! That’s the problem of using WordPress plugins, you start forgetting the basics!

  3. Caro Creative Web Design Oxfordshire says:

    Great tips collection. A mine gold I might say.

    Thanks,

    LC

  4. Scott says:

    clearly an old article based on the timestamp of the comments, but one major miss here is which is commonly misused to render icons.

    per mdn:
    The HTML
    Element represents a range of text that is set off from the normal text for some reason, for example, technical terms, foreign language phrases, or fictional character thoughts. It is typically displayed in italic type.

    not for icons…

  5. web design hessle says:

    Useful article, I didn't even know about the <small> tag

  6. W3Spor says:

    Thanks, useful information about correct coding… I need it!

  7. Christie says:

    I'll admit.. I use the small tag to make small text when I am lazy :D

  8. Jo Cox says:

    Great article, never used the <address> tag before, you learn something new every day!

  9. S3bY says:

    Great tips collection! A mine gold I might say for a beginner!

  10. Majalah says:

    ocassionally I still use <br / > for dirty solution :D

  11. D says:

    So…what, semantically, is a mailing address? Gotta admit I've been using <address>. It ain't a <p> or a <div>, etc… help?

    Great article!

  12. Matthew Dickens says:

    It drives me CRAZY when I see multiple <br> tags in a row!!
    <br><br>
    This was a good article. Thank you.

  13. matiangul says:

    Thanks for lesson of semantic code. Great and short article.

  14. Clain Dsilva says:

    Good article,

    I agree with the misuse of <BR> and <hr> tags.. I have seen many while I do a rework on already done websites.

    Another notorious one is use of "&nbsp;" to put more than one space.

  15. Brad says:

    But..its so much easier to not understand them when its obvious they are self explanatory

    < / sarcasm off >

  16. Mike says:

    Great resource, so many times I see websites that are poorly built and I think you make your argument very clear.

    I also really don't like WYSIWYG editors that so badly encode pages, it breaks my heart! Ok maybe not that extreme, but still….

  17. web designer Abu dhabi says:

    Excellent article. thanks for doing this nice job!

  18. web site design says:

    how come u know about the <small> ?

  19. JimJ says:

    Possibly "misuse" is a bit extreme in a couple of cases, but generally a good article. Cheers

  20. Chris F.A. Johnson says:

    Where did you get the idea that "The <small> HTML tag is reserved for defining “smallprint” or legal text"?

  21. Logo Blog says:

    Very nice beginning information! Great way of explanation! which i like most! i will look forward for a new lesson! thanks for doing this nice job!

  22. Tony says:

    Mistakes we all made in the beginning ;) I think….

  23. Xtreme Websites says:

    This was a great post. I was a good reminder of the complexities of web page design.

  24. German Translation says:

    Excellent article as always.. The <br> tag is a pet peeve of mine ;)

  25. Christian says:

    Speaking of HRs I see people use graphic elements on pages all the time that are just images inserted into the flow of the document when they should really be background images on an HR element.

  26. Christian says:

    Back when XHTML started to get some visibility it included the promise of being able to create your own elements since it was a blend of HTML and XML. So I remember thinking (ten years ago) that if you created an element that was for surrounding a postal address on a contact page that element would very like be called . . . drum roll, please . . . ADDRESS. But people get on your case for using the ADDRESS element for marking up postal addresses but even with HTML5 there is no adequate mechanism for it apart from a generally messy combination of DIV and SPAN elements, such as the microformats generator churns out.

  27. Kristan says:

    The <small> tag should not be used to make text small??

    *doh*!

    Poorly chosen tag name, that.

    • Jason Lafferty says:

      I'd be interested to read more specifically about the < small > tag, as rather than being for legal text I'm guessing that it was designed for using with disclaimer text (ie. any declarations at the bottom of the page, legal or otherwise). Would provide a slightly wider use for the tag.

      I must point out that I never use it though! :)

  28. georgecalm says:

    Nice list. Thanks!

  29. Alex says:

    Nice list, but still even you are not using the breakline tag correct.

    Because the correct tag is <br /> and not <br>

    • Rasmus Lauridsen says:

      Only if he is doing XHTML.

      HTML defines <br> without closing the tag.
      XHTML on the other hand, being XML does not allow unclosed tags so it uses <br />.

  30. ardianzzz says:

    Yeah! validation nonsense without semantic code.

  31. custom icon design says:

    it's great resource, I have noticed I misused many tags. So I decide to re-study the css or html.

  32. Ali Rowan says:

    Thanks for the tips! As someone who remembers learning HTML from the all-mighty Neopets at the age of ten and wants to pick it back up legitimately this time, I found this exceptionally helpful in how digestible you've made the information.

  33. Spencer says:

    This was a great refresher.

  34. vijay says:

    Nice article, Thanks to point out the misuse of these tags. specially <div> tag which is overused by many designers, now we can use new and more semantic HTML5 tags like <article>, <header>, <footer> etc.

  35. Katie says:

    I always use CSS to make my font small for legal text, but now I will definitely use "small". Didn't know it even existed. Thanks

  36. antjanus says:

    I'm pretty sure that the address tag is irrelevant today and for the purposes of SEO and parsing by services, one should stick to microformats :)

  37. Marco Berrocal says:

    I dislike designs that resort to using <br>, <small>, but maybe it's more of a pet peeve of mine.

  38. Nick West says:

    I would add that the IMG tag is also misused by using it for style elements rather than setting those style elements as a background-image in the CSS.

    IMG should be reserved for user content. If the image looks out of place or weird when you disable your style sheet, it probably shouldn't be an IMG or you should consider cutting it differently.

  39. Marlou says:

    Thanks for this list.
    Is <small> still used in HTML5? I've actually never used the adress-tag before, shame on me. Should remember that one.

  40. Emil Melgaard says:

    It should be noted that the for attribute in the label tag can be left out if the label tag is wrapping around the input element.

    Fx.

    <label>
    A radio button
    <input type="radio" name="radio" title="radio" id="radio" />
    </label>

  41. Ryan says:

    "If the image is being used as a link give an insight to where the link will go."

    Isn't that what the title="" tag on the link is for? The alt="" tag will only ever describe the image in my code :)

    • Ash says:

      I am in agreement with this, stick the title on the <a> and keep the alt on the <img> to describe the image.

    • Rob Saunders says:

      Uh oh… that's wrong. Think about your markup as if you are blind (which essentially is what semantic markup is about… the visual representation may have no bearing on the meaning of the content).

      If you are relying on a screen reader to navigate, you don't actually care what the image visually displays, just what it represents.

      I remember looking at alt tags of one of the biggest news papers in Australia, and they'd alt-tagged an image link to an article about mature people exercising more as 'bowl of fruit with a man behind it'. It is what the image contained, but not what it represented.

      A very important and an easy mistake to make.

      • Gert says:

        You have the title tag to tell blind people what the image represents. The alt tag is to tell what it is.

        So if it's an image of a car, it's fine to say in the alt tag that it's an image of a Porsche 550 Spyder. The title tag is used to tell that it's the car where James Dean crashed in and died.

        And that's not only for blind people. If the images is removed from the host, non-blind users will also see the alt tex instead of the image. Then it's still perfectly acceptable to display the text Porsche 550 Spyder (or "image of silver coloured Porsche 550 Spyder") and still use the title tag to give some more information.

  42. Andrew says:

    Not sure I agree on the statement that in some cases an empty ALT tag is acceptable. From what I understand, an empty alt tag won't pass validation (but maybe I'm thinking of "missing" as oppose to "empty").

    But in any case, I can't think of too many reasons why NOT to put an ALT tag. You don't have to keyword stuff it to death… but the more opportunities to add content, the better. No?

    • Timothy McClanahan says:

      If you have an image that is nothing but decoration, there is a good chance it needs no alt text. A MISSING alt attribute will trigger a validation error, but if the alt attribute is there but empty, it'll validate just fine.

  43. Yentl (Design 311) says:

    Thanks for these. I must admit that I do use the small tag for small text, rather than for legal text.

  44. Laura says:

    Oh my gosh – I've been misusing the address tag for years! I feel like a moron!

  45. Stephen says:

    We call the overuse of <div> tags "div-itis". Easy to get carried away with sometimes. Nice article.

  46. Russell Bishop says:

    Not sure I agree on the common misuse of the horizontal rule. It's fine to use it as a long break in a blog post, in order to indicate a shift in subject.

    • Chris Spooner says:

      That sounds like a perfectly reasonable use to me. As for misuses you often see it used just to insert a line somewhere in a design, rather than it having a particular use as a HTML element.

Please Share