扩展HTML5标签集合

PHP*_*Pst 2 html xml html5

如你所知HTML5引入了一些新的html标签,如页脚,标题,......

什么阻止我们使用很多其他新标签并将shiv应用于这些新标签?(从功能,行为,风格,结构,...观点)

我想使用以下代码(更多语义,简洁和可读,向前迈进Web 3.0):

<style type="text/css">
    book {
        display: block;
        color: red;
    }

    book title {
        display: inline-block;
        font-weight: bold;
    }
</style>

<book>
    <title>
        My Title
    </title>
</book>
Run Code Online (Sandbox Code Playgroud)

而不是使用以下传统(!)代码:

   <style type="text/css">
        div.book {
            color: red;
        }

        div.book div.title {
            font-weight: bold;
        }
    </style>

    <div class="book">
        <span class="title">My title</span>
    </div>
Run Code Online (Sandbox Code Playgroud)

Ant*_*ann 5

这似乎是RDFa的一个用例.实际上,RDFa规范中有一个非常类似的例子.这是你可以做的(我知道,它比你提出的更冗长,但谁说更多的语义意味着更简洁?)

<html
  xmlns="http://www.w3.org/1999/xhtml"
  prefix="bibo: http://purl.org/ontology/bibo/
          dc: http://purl.org/dc/terms/"
>
  <head>
    <title>Title of the web page</title>
    <style type="text/css">
      div[typeof="bibo:Book"] {
        color: red;
      }
      span[property="dc:title"] {
        font-weight: bold;
      }
    </style>
  </head>
  <body>
    <div typeof="bibo:Book">
      <span property="dc:title">My title</span>
    </div>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

在这里,你说有一个类型的实体bibo:Book(你需要定义一个引用词汇表的命名空间,这里是参考书目本体),这个实体有一个dc:title(同样,属性在都柏林核心词汇表中定义).你可以看到我正在使用CSS2选择器来适当地格式化这本书.