Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In which element should I enclose an <article />'s comments?

I'm working on a blog that implements Disqus comments and I'm making an effort to make as much use of HTML5 semantic markups as possible.

Here's an example <article /> (itself within a <section />), fairly simple:

  <article class="post">
    <header>
      <h2>Title</h2>
      <p class="posted-on">Posted on <time datetime="2012-07-28T13:00:24+01:00">July 28th 2012</time>.</p>
    </header>
    <p>Lorem ipsum dolor sit amet...</p>
    <p>Lorem ipsum dolor sit amet...</p>
    <!-- blog comments -->
  </article>

With the above structure, I'm unsure semantically where to integrate the article's comments.

  • A <footer /> is clearly not appropriate ("The footer element is not sectioning content; it doesn't introduce a new section.")
  • Disqus uses async JavaScript to create an <iframe /> to contain the comment widget, so a <p /> doesn't seem appropriate, either.

Am I over-thinking the semantic markup thing: is it best to just stick it into a <div /> and not worry about it?

like image 563
msanford Avatar asked Sep 28 '12 16:09

msanford


People also ask

What does an article element contains?

The <article> HTML element represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable (e.g., in syndication).

What is the correct way to comment out in HTML?

To “comment out” in HTML, simply place the < ! ╌ ╌> tags around the code you want to hide. These tags will tell browsers not to render this code on the front end. Commenting out has two main purposes.

How do you insert comments in HTML?

HTML <!--...--> Tag The comment tag is used to insert comments in the source code. Comments are not displayed in the browsers.

Which of the following is used to represent comment in HTML?

Explanation: To comment out something in HTML, we have to place the information between the <! —and --> tags. Comments are some text or code which provides an explanation about the code and not visible to the user.


2 Answers

There is an example in the HTML5 spec for a blog post with comments. Which makes sense, in my opinion.

Your example could look like:

  <article class="post">
    <header>
      <h1>Title</h1>
      <p class="posted-on">Posted on <time datetime="2012-07-28T13:00:24+01:00">July 28th 2012</time>.</p>
    </header>
    <p>Lorem ipsum dolor sit amet...</p>
    <p>Lorem ipsum dolor sit amet...</p>

    <section>
      <h1>Comments</h1>

      <article><!-- comment 1--></article>
      <article><!-- comment 2--></article>
      <article><!-- comment 3--></article>

    <section>

  </article>

Side note: I think your "posted-on" would better fit into a footer instead of a header. So your header could be omitted because it would only contain the heading. So your example could look like:

  <article class="post">

    <h1>Title</h1>

    <footer class="posted-on">Posted on <time datetime="2012-07-28T13:00:24+01:00">July 28th 2012</time>.</footer>

    <p>Lorem ipsum dolor sit amet...</p>
    <p>Lorem ipsum dolor sit amet...</p>

    <section>
      <h1>Comments</h1>

      <article><!-- comment 1--></article>
      <article><!-- comment 2--></article>
      <article><!-- comment 3--></article>

    <section>

  </article>
like image 52
unor Avatar answered Sep 29 '22 12:09

unor


You could stick it in its own <section> (rather than a <div>) within your containing <section>, as a sibling of your <article>. But if you're using Disqus, I guess whichever element you use doesn't matter. I don't think it belongs within the article content though. Maybe an <aside> instead?

Just keep in mind that when it comes to semantics, there aren't any hard and fast rules. As long as your document is structured and outlined in a meaningful way, that's what matters.

like image 41
BoltClock Avatar answered Sep 29 '22 14:09

BoltClock