HTML Tips & Tricks

We publish an HTML tip or trick every week on this page, on our RSS feed or directly delivered to your inbox via our newsletter.

  1. Issue #8 - the section element

    Use the <section> element to mark up a grouping of related content, typically introduced with a heading.

    <h1>Welcome to GOV.UK</h1>
    <section>
    <h2>Services and information</h2>

    </section>
    <section>
    <h2>Departments and policy</h2>

    </section>
    An extract of the gov.uk home page.

    Continue reading Issue #8
  2. Issue #7 - the avif image format

    avif is a fairly new image format and for me it's one of the most exciting recent additions to web development. Why? On a website I recently built, I could reduce the total image size from 1.72MB to 172KB just by converting images to avif.

    Continue reading Issue #7
  3. Issue #6 - the document outline

    In May to June 2021, WebAIM surveyed preferences of screen reader users and the results show that most respondents find proper heading structures useful.

    Pie chart showing that 52.8% find headings very useful and 32.9% somewhat useful.

    Continue reading Issue #6
  4. Issue #5 - autocompleting password fields

    You can help password managers and browsers (pre)fill password fields by using the autocomplete attribute,...and by doing other stuff.

    <label for="new-password">New Password</label>
    <input type="password" autocomplete="new-password" id="new-password" name="new-password" />
    Continue reading Issue #5
  5. Issue #4 - the current page

    Use the aria-current attribute to highlight the current page in a navigation, both visually and semantically.

    <nav>
    <ul>
    <li><a href="/home">Home</a></li>
    <li><a href="/about-us" aria-current="page">About us</a></li>
    <li><a href="/contact">Contact</a></li>
    </ul>
    </nav>
    Continue reading Issue #4
  6. Issue #3 - page descriptions

    You can describe web pages using meta tags. This is important for 3rd party tools, websites, and apps. Search engines may use the description in their search results and social media sites in previews when users post a link.

    <meta name="description" content="HTML, accessibility, performance, and SEO tips, tricks, and best practices.">
    <meta property="og:description" content="HTML, accessibility, performance, and SEO tips, tricks, and best practices.">
    Continue reading Issue #3
  7. Issue #2 - gifs and reduced motion

    You can show animated gifs only if users don’t prefer reduced motion and fall back to jpg, using the picture element in combination with the prefers-reduced-motion media feature.

    <picture>
    <source srcset="pooh666.gif" media="(prefers-reduced-motion: no-preference)">
    <img src="pooh666.jpg" alt="Pooh Bear doing knee bends in front of a mirror. Instead of the mirror glass, there’s an illustration of Satan. It looks like Pooh is worshipping the devil.">
    </picture>
    Continue reading Issue #2
  8. Issue #1 - iframe accessibility

    iframes should be named, if they contain meaningful content. You can define an accessible name for an iframe using the title attribute. If it’s missing, screen readers might fall back to the value of the name or src attribute, which makes it hard or impossible for users to understand the purpose of the iframe.

    <iframe title="Bob Dylan - Visions Of Johanna (Live 1966) YouTube" width="560" height="315" src="https://www.youtube.com/embed/uW9_2r3raHE"></iframe>
    Continue reading Issue #1
  9. Issue #0 - Download links

    You can turn a hyperlink into a download link by adding the download attribute. Instead of navigating to the document, browsers prompt users to save the file to their disc.

    <a href="myfile_hash5474n.pdf" download>
    Annual Report (666 KB)
    </a>
    Continue reading Issue #0

Do you like what you’re reading?

Sign up for the HTMHell newsletter and receive an HTML tip or trick every week via e-mail.