在W3C中特别提到
This specification defines the HTML microdata mechanism. This mechanism allows machine-readable data to be embedded in HTML documents in an easy-to-write manner, with an unambiguous parsing model. It is compatible with numerous other data formats including RDF and JSON.
要使用Microdata增加网页的可读性,需要有基本HTML概念,如果只会使用Dreamweaver视觉化方式设计网页,而不会使用文字模式编写网页就不适合。
基础网页语法
首先需要使用itemscope标签包裹itemprop属性。
我的名字叫王大明。
作者的名字是张铭伦。
在itemprop属性中如果包含其他html语法不会影响Microdata读取结果,Microdata只会读取文字叙述,并不会将文字叙述中包含的网页语法列入考量,所以有些人想要透过加入或是之类的标签强化特定文字,对于Microdata来说是多余的。
进阶Typed items语法
有些第三方单位,特别将Microdata进行了分类,以便更清楚的将资讯显示在他们的数据库中,这时候我们需要使用itemtype这个标签将第三方的类别网址引入,最具指标性的单位就是Schema. org。
在Schema.org的网站中提到:
Schema.org is sponsored by Google, Microsoft, Yahoo and Yandex. The vocabularies are developed by an open community process, using the public-schemaorg@w3.org mailing list and through GitHub.
目前较知名的搜索引擎Google, Microsoft, Yahoo 和Yandex都支持Schema.org。
所以为了让这几个搜索引擎更方便了解我们的网页,似乎itemtype这个标签是很重要的,我们可以进入schema.org的Full Hierarchy查看支援那些分类项目。
itemscope itemtype="http://schema.org/AggregateRating">
建设网站公司
分数6/10
(根据19 个网友的评价)
因为每个分类项目有不同的itemprop属性需求,我们可以利用Google提供的结构化资料测试工具测试我们写的网页是否有缺漏的宣告或是该分类有建议的itemprop属性,透过线上检测工具可以针对结果改善网页设计。
JSON for Linking Data
我们会发现,在网页语法中增加了那么多的标签,虽然帮助搜索引擎更了解我们的网页,但是对于网页画面呈现于网友面前的结果并不会有不同处,对于html语法有精简要求的工程师,这时候可以利用JSON for Linking Data将Microdata从html中抽离,透过