views:

28

answers:

2

I'm new to HTML and want to make semantically correct HTML, however I'm finding it hard to work with what seems to be only headings, lists and paragraphs.

Particularly, I can't find a place that makes sense for subtitles. I'm writing a blog site so lets use that as an example:

A BLOG TITLE
the best blog in the world

post_title1
post_title2
post_title3

Semantically 'A BLOG TITLE' is h1. It makes sense to me that the post_titleX are h2, but it doesn't feel right for the subtitle - 'the best blog in the world' to be classed at the same level as them.

+1  A: 

I would just use a paragraph element, it doesn't feel as odd to me as using a heading element:

<p class="subtitle">the best blog in the world</p>

You's answer ("your answer", "his answer"?) would certainly be the way to go if you're marking up using HTML5.

BoltClock
Hmm. That does make more sense than headings.
JonoRR
I agree - since the subtitle is more of a description than any kind of title. If you think of it that way, the `p` tag makes perfect sense.
ClarkeyBoy
But the subtitle is (as its name implies) a title, and *should* therefore be a `h2` element. In HTML4, where we can't associate (or couple) `hX` elements like we can in HTML5, we have to resort to this slightly less semantic solution.
You
Right. I guess the definition of a 'paragraph' is a bit restricting. More like content?
JonoRR
+2  A: 

In HTML5, there's an obvious solution:

<header>
    <h1>A BLOG TITLE</h1>
    <h2>the best blog in the world</h2>
</header>

When using HTML4 I personally tend to replace the h2 with p class="tagline", or something similar.

Edit: To motivate the use of h2 in HTML5, think of the title of Dr. Strangelove:

<h1>Dr. Strangelove</h1>
<?>Or: How I Learned to Stop Worrying and Love the Bomb</?>

Does a p element make sense here? Not really — it's not a paragraph, it's a title. Does h2 work as-is? No, we might confuse it with subtitles of the text itself. So what do we do? We use h2 and group it with h1 using a header element, thereby getting rid of the ambiguity concerning the subtitles in the text.

You