1

When you are reading blog post, on almost all blogs, there is a "sidebar" with similar articles, latest comments, etc. In the layout I'm going to implement, I've got a huge article header (with photo, and trailer) with the 100% width. After that, I've got article body, with described sidebar, and after that, I've got (once again 100% width) author information, and comments.

In that case, I cannot escape with the "sidebar" out of the main article tag. Minimal example:

<article>

    <!-- ARTICLE HEADER -->
    <header style="width: 100vw; height: 100vh">
        <h1>title</h1>
        <p>trailer</p>
        <time>...</time>
    </header>

    <!-- ARTICLE BODY -->
    <h2>...</h2><p>...</p><ul>...</ul> x few

    <!-- SIDEBAR - PROBLEM -->
    <div id="sidebar">
        <h2>Similar articles</h2><ul>...</ul>
        <h2>Latest comments</h2><ul>...</ul>
    </div>

    <!-- ARTICLE FOOTER -->
    <footer id="author" style="width: 100vw; height: 100vh">
        <h1>Details</h1>
        <section>
            <h1>Author</h1>
            <address>...</address>
        </section>
        <section>
            <h1>Comments</h1>
            <ul>...</ul>
        </section>
    </footer>

</article>

The problem is with div#sidebar and what kind of element it sohuld be in.

  • This of course is not the part of article (so it cannot be div)
  • This is probably not aside (aside inside of article is highly related to article, but can be ommited while reading, and this sidebar is auto generated and not related to article at all)
  • This is probably a section, but of course should not be inside of article tag
  • There is no chance, to make this element out of article, and make is simple section, because the positioning (absolute, or flex) will be to difficult to manage, because of the full screen footer and header.

Any help?

I've got a solution using jquery, I can cut the element out of the "flow", and paste it somewhere else, but maybe there is a semantic solution using HTML5 only?

labilbe
  • 3,501
  • 2
  • 29
  • 34
Jacek Kowalewski
  • 2,761
  • 2
  • 23
  • 36
  • Why not put the article body in `
    ` and give it like a 75% width and the related links in an `
    – DC319 May 18 '16 at 17:05
  • Something like [this](https://codepen.io/dpcobb/pen/ZWNdwX) – DC319 May 18 '16 at 17:20
  • Header and footer I'm atlking about are the header and footer of article. They must be inside article tag, to make crawlers understand it. In your example, the header and footer are inside and they are considered to be a footer and header of a page, not article. However, thx for the information about aside. I will give it a try. Please, make an answer, and link, confirming that: "aside is content that is somewhat related, but separate from the content itself". I will accept it, and give it +1 :). Thanks a lot. – Jacek Kowalewski May 19 '16 at 13:37
  • PS. ASIDE - "When used within an article element, the contents should be specifically related to that article (e.g., a glossary). When used outside of an article element, the contents should be related to the site" - http://html5doctor.com/aside-revisited/ - So it is not obvious that aside is ok here... :( – Jacek Kowalewski May 19 '16 at 13:39
  • 1
    I think that article is a bit dated, the most recent [W3C recommendation](https://www.w3.org/TR/html5/sections.html#the-aside-element) for ` – DC319 May 19 '16 at 15:31
  • PS. You can read about display: flex in the free time. It is much better than old float, and display: inline-block methods :). – Jacek Kowalewski May 19 '16 at 17:07

1 Answers1

2

Why not put the article body in <article> and give it like a 75% width and the related links in an <aside> with a 25% width and float them both? The <aside> tag is used for content that is somewhat related, but separate from the content itself. Related links are def. a fit for <aside>.

codepen

W3C information on <aside>

DC319
  • 119
  • 1
  • 3
  • 1
    Thanks a lot for the W3C link. I didn't know about the latest changes in aside spec. I hope it will be usefull for others in the future. Best regards! – Jacek Kowalewski May 19 '16 at 17:04