skip to Main Content

I would like to place a heading in Vuetify.

I noticed that you could use either the <h1> element or the text-h1 class. What is the difference between them? It seems that the latter one has a bigger font size.

So I came up with three ways:

<h1>Heading 1</h1>
<div class="text-h1">Heading 1</div>
<h1 class="text-h1">Heading 1</h1>

Which one is the recommended way of placing a heading?

3

Answers


  1. This can be figured out by simply opening your browser’s dev tools and inspecting the element. The class text-h1 will have some CSS associated with it.

    DOM inspector


    .text-h1 {
        font-size: 6rem !important;
        font-weight: 300;
        line-height: 1;
        letter-spacing: -0.015625em !important;
        font-family: "Roboto", sans-serif;
        text-transform: none !important;
    }
    

    Which one is the recommended way of placing a heading?

    It’s up to you decide what style you prefer, there is no right or wrong answer.

    Login or Signup to reply.
  2. The main difference between using a <div> and a <h1> is the HTML semantics.

    Please refer to Semantics in HTML documentation to find out why they’re important.

    Some of the benefits from writing semantic markup are as follows:

    • Search engines will consider its contents as important keywords to influence the page’s search rankings (see SEO)
    • Screen readers can use it as a signpost to help visually impaired users navigate a page
    • Finding blocks of meaningful code is significantly easier than searching through endless divs with or without semantic or namespaced classes
    • Suggests to the developer the type of data that will be populated
    • Semantic naming mirrors proper custom element/component naming
    Login or Signup to reply.
  3. Using H1 tag versus text-h1 class has the following differences:

    Visual vs Semantic Meaning

    While you might see little visual difference, using the H1 tag communicates to search engines that the text within this tag contains the most important keywords on your page and helps with SEO optimization. When using other tags with styling classes, they carry no semantic meaning for search engines.

    Important Note

    Each page should contain exactly one H1 tag.

    Code Example

    <!-- Recommended for main heading -->
    <h1>Main Page Title</h1>
    
    <!-- Not recommended for main heading -->
    <div class="text-h1">Main Page Title</div>
    

    SEO Impact

    The H1 tag:

    • Defines the main heading of the page
    • Helps search engines understand page hierarchy
    • Improves content indexing
    • Contributes to better search engine rankings
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search