6

私は新しいHTML5要素とその適切な使用法について読んでおり、現在、次のようなマークアップがあります。

    <article>
        <h1>Crazy Awesome Programming Projects</h1>
        <article>
            <h2>Mathematics</h2>
            
            <section>
                <h3>Binary to Decimal converter</h3>
                <p> info here </p>
            </section>
            
            <section>
                <h3>Scientific Calculator</h3>
                <p> info here </p>
            </section>
            
        </article>
        
        <article>
            <h2>String Manipulation</h2>
            
            <section>
                <h3>RSS Feed Generator</h3>
                <p> info here </p>
            </section>

            <section>
                <h3>Palindrome Detector</h3>
                <p> info here </p>
            </section>
        </article>
    </article>

<article>このような方法でタグをネストすることは意味的に正しいですか?

4

2 に答える 2

9

ネストarticle要素が正しい場合があります。最も顕著なケースは、ブログ投稿へのコメントです。

しかし、私はあなたの例には当てはまらないと思います(ただし、完全なコンテンツを見ずにこれを決定するのは難しいです)。

私はそれをまったく逆に行います:

<section> <!-- probably not article -->
    <h1>Crazy Awesome Programming Projects</h1>

    <section> <!-- not article -->
        <h2>Mathematics</h2>

        <article> <!-- not section -->
            <h3>Binary to Decimal converter</h3>
            <p> info here </p>
        </article>

        <article> <!-- not section -->
            <h3>Scientific Calculator</h3>
            <p> info here </p>
        </article>

    </section>

    <section> <!-- not article -->
        <h2>String Manipulation</h2>

        <article> <!-- not section -->
            <h3>RSS Feed Generator</h3>
            <p> info here </p>
        </article>

        <article> <!-- not section -->
            <h3>Palindrome Detector</h3>
            <p> info here </p>
        </article>
    </section>
</section>

「2進化10進コンバーター」、「関数電卓」、「RSSフィードジェネレーター」、「パリンドローム検出器」はこちらの記事です。それらは「自己完結型の構成」であり、「原則として、シンジケーションなどで独立して配布または再利用可能」です。

「数学」と「文字列操作」はカテゴリです。

構造的にはウェブショップに似ています。「PalindromeDetector」は購入可能な製品であり、「StringManipulation」は製品カテゴリです。製品カテゴリを「自己完結型」とは見なさないでしょう。

コンテナ(「CrazyAwesome Programming Projects」)には、articleコンテキストを提供するコンテンツがもっとある場合にのみ使用します。それ以外の場合は、「実際の」コンテンツを含むサブカテゴリを含む、単なるトップカテゴリです。

article適切かどうかを尋ねる良い質問:

  • コンテンツに独自の公開日を設定できますか?
  • コンテンツの作成者がページと異なる可能性はありますか?
  • コンテンツをフィードの個別のエントリにすることはできますか?
  • 他のコンテンツ/コンテキストなしで印刷された場合でも、コンテンツは意味がありますか

これらの質問(の一部)が「はい」で答えられた場合、article正しい可能性があります。

于 2013-02-03T20:20:52.510 に答える
8

はい、HTML5仕様によると。これは、ネストarticle要素についての説明です。

記事要素がネストされている場合、内側の記事要素は、原則として外側の記事のコンテンツに関連する記事を表します。たとえば、ユーザーが送信したコメントを受け入れるサイトのブログエントリは、ブログエントリのarticle要素内にネストされたarticle要素としてコメントを表すことができます。

于 2013-02-02T04:08:21.777 に答える