I am trying to write high quality semantic HTML5.
Which of the following two options are better semantically:
OPTION 1:
Define the styles by selecting spans using IDs:
%body
%header#global-header
%h1
My Startup Name
%h2
Home of the best offers in the Motor City
%section#offers
%h1
Today's Offers
%h2
Here are the current offers for your city:
%article.offer
%header.offer-header
%span.restaurant-name
Some Burger Joint
%span.offer-title
80% off a burger
%section.price-details
%ul
%li.original-price
%p
Original Price
%p
$30
%li.offer-price
%p
Price
%p
$10
%section.offer-description
%p
Some burger joint is the most popular burger joint in the Motor City. Buy a big burger or a bunch of belly bombers.
%article.offer
...another offer...
Under this option I would select and style the restaurant-name and offer-title with something like this in SASS:
body {
h1 { font-size: 3em; }
h2 { font-size: 2em; }
article {
.restaurant-name { font-size: 1.25em; }
.offer-title { font-size: 1.5em; }
}
}
OPTION 2:
Using h1 to h6 by scoping the styling to within and tags by class or id:
%body
%header#global-header
%h1
My Startup Name
%h2
Home of the best offers in the Motor City
%section#offers
%h1
Today's Offers
%p
Here are the current offers for your city:
%article.offer
%header.offer-header
%h2.restaurant-name
Some Burger Joint
%h3.offer-title
80% off a burger
%section.price-details
%ul
%li.original-price
%h4
Original Price
%h4
$30
%li.offer-price
%h4
Price
%h4
$10
%section.offer-description
%p
Some burger joint is the most popular burger joint in the Motor City. Buy a big burger or a bunch of belly bombers.
%article.offer
...another offer...
Under this option I would select and style the restaurant-name and offer-title with something like this in SASS:
body {
h1 { font-size: 3em; }
h2 { font-size: 2em; }
article {
%h1 { font-size: 1.25em; }
%h2 { font-size: 1.5em; }
}
}
With Option 1, I am defining the style using IDs to select the element and style it. With Option 2, I am defining the style by using styles for h1 to h6 again but those styles are scoped to the article and not the entire document. The enclosing page has h1 and h2 tags for the titles and subtitles for the entire.
Are h1 to h6 tags only supposed to be used in one way throughout a whole site? Or is it okay to scope h1 to h6 within major pieces of a site? For example, in the site above the section with id offers is going to be a major piece of the site and there will be other sections of similarly significant importance.
I get the impression that option 1 is more maintainable as it is more descriptive. However, there is nothing keeping me from still using IDs in Option 2 to achieve the same maintainability. Option 2 strikes me as being better insofar as keeping the code lean and my html and css files smaller.
I'm not sure if one is in fact better than the other semantically, especially if I use IDs liberally in both. That still leaves us with the question of which is better semantically for my use case, h1-h6 or spans?
I hope all that made sense. Let me know if I need to be clearer.