Tabla de Contenidos

Frontend Guidelines

HTML

Semantics

HTML5 provides us with lots of semantic elements aimed to describe precisely the content. Make sure you benefit from its rich vocabulary.

  <!-- bad -->
  <div id="main">
    <div class="article">
      <div class="header">
        <h1>Blog post</h1>
        <p>Published: <span>21st Feb, 2015</span></p>
      </div>
      <p>…</p>
    </div>
  </div>
  
  <!-- good -->
  <main>
    <article>
      <header>
        <h1>Blog post</h1>
        <p>Published: <time datetime="2015-02-21">21st Feb, 2015</time></p>
      </header>
      <p>…</p>
    </article>
  </main>

Make sure you understand the semantic of the elements you’re using. It’s worse to use a semantic element in a wrong way than staying neutral.

  <!-- bad -->
  <h1>
    <figure>
      <img alt=Company src=logo.png>
    </figure>
  </h1>
  
  <!-- good -->
  <h1>
    <img alt=Company src=logo.png>
  </h1>

Brevity

Keep your code terse. Forget about your old XHTML habits.

  <!-- bad -->
  <!doctype html>
  <html lang=en>
    <head>
      <meta http-equiv=Content-Type content="text/html; charset=utf-8" />
      <title>Contact</title>
      <link rel=stylesheet href=style.css type=text/css />
    </head>
    <body>
      <h1>Contact me</h1>
      <input type=email placeholder=you@email.com required=required />
      <script src=main.js type=text/javascript></script>
    </body>
  </html>
  
  <!-- good -->
  <!doctype html>
  <html lang=en>
    <meta charset=utf-8>
    <title>Contact</title>
    <link rel=stylesheet href=style.css>
  
    <h1>Contact me</h1>
    <input type=email placeholder=you@email.com required>
    <script src=main.js></script>
  </html>
  

Accessibility

Accessibility shouldn’t be an afterthought. You don’t have to be a WCAG expert to improve your website, you can start immediately by fixing the little things that make a huge difference, such as: