您在网络项目中使用微格式吗?

发布于 2024-09-03 15:27:39 字数 1432 浏览 5 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

偏爱自由 2024-09-10 15:27:39

我相当广泛地使用了微格式。我看到的好处是

  • 可以访问机器人的数据,例如 Google Rich Snippets
  • 通过 µF-comsuming 工具(例如 H2VX)为用户访问数据
  • (某些),数据验证
  • 更有意义标记,这让我很高兴

(小)缺点是

  • 时间;手工编码这些东西可能是一个皮塔饼。以编程方式添加(例如从 CMS 中的数据生成)或制作一堆片段。如果通过 CMS 进行,那么(对我来说)
  • 需要额外关注 UI 才能做得很好(最好是暴露出来,但这通常涉及自定义图标等)

微格式在 HTML5 中可以正常工作。有一些新的 HTML5 元素可以很好地映射到某些 µF 函数,特别是 ,但请注意 当前的 µF 工具普遍无法应对 HTML5 的新元素(“工具支持”幻灯片)

您的其他选择是 HTML5 的微数据,和 RDFa。微数据非常好,但很新,所以没有很多可用的工具。您可以在微数据中表示微格式,HTML5 规范具有 vCard 和 vCal 的微数据版本。还有 HTML5 data- 属性,但这是供私人使用的,不会对可见数据进行编码,因此可能不是您想要的。

我认为这三个是一个连续体,从简单但具体(微格式)到困难但无所不能(RDFa),微数据(对我来说)占据了中间的最佳位置。 Google Rich Snippets 可以读取其中任何一个中的数据,但用户工具仍在追赶。其中任何一个的主要好处是通过公开更多信息使您的内容更有用,对我来说这通常值得花时间。

为了完整起见,我使用了

  • hCard
  • hCalendar
  • hEvent
  • hAtom
  • hReview (一次?:)
  • XFN
  • 加上一些像 rel-license 的 rels

编辑:我在 HTML5Doctor 包含您需要了解的一切;)

HTH

I’ve used microformats fairly extensively. The benefits I see are

  • access to data for robots like Google Rich Snippets
  • access to data for users via µF-comsuming tools like H2VX
  • (some) data validation
  • more meaningful markup, which makes me happy

(minor) disadvantages are

  • time; hand-coding these things can be a pita. Either add programmatically (e.g. generate from data in CMS) or make a bunch of snippets. If doing via a CMS then it’s (for me) a no-brainer
  • require extra attention to UI to do well (best if exposed, but that often involves custom icon etc)

Microformats work fine as-is in HTML5. There are new HTML5 elements that map well to some µF functions, notably <time>, but be warned that current µF tools generally can’t cope with HTML5’s new elements (“Tool support” slide).

Your other alternatives are HTML5’s microdata, and RDFa. Microdata is pretty nice, but quite new so doesn’t have many tools available. You can represent microformats in microdata, and the HTML5 spec has microdata versions of vCard and vCal. There’s also HTML5’s data- attribute, but that’s for private use and doesn’t encode visible data, so is probably not what you’re after.

I perceive these three as a continuum from easy but specific (microformats) to hard but capable of anything (RDFa), with microdata (for me) occupying a sweet spot in the middle. Google Rich Snippets can read data in any of these, but user tools are still playing catchup. The main benefit of any of these is making your content more usable by exposing more of the information, and for me that’s generally worth the time.

For completeness I’ve used

  • hCard
  • hCalendar
  • hEvent
  • hAtom
  • hReview (once? :)
  • XFN
  • plus some rels like rel-license

EDIT: I’ve written these articles on HTML5Doctor with everything you need to know ;)

HTH

っ〆星空下的拥抱 2024-09-10 15:27:39

HTML5 定义了各种语义标签来标记您的数据:

它还允许自定义 数据属性,在元素内以 "data-" 开头。

支持 microdata,它基于微格式,提供更多信息个人和群体的语义结构的元素。

并回答您的主要问题:

不,我不使用微格式,因为直到我认真思考您的问题之前我没有看到它的优点。我使用的是较新的 HTML5 元素,例如时间和自定义数据属性,但不是微格式,因为数据已经在后端结构化,并且为了更加结构化和语义访问,我会使用具有特定扩展名的 RSS 提要和在文档本身中包含一个到 feed 的链接。

也就是说,这就是为什么我仍然支持微格式并相信它们很棒并且很可能在不久的将来开始使用它。对我来说,它有一个非常具体的目的,并且与以编程方式访问我的 Web 应用程序中的元素有关。 RSS 和 Atom 提要以非常结构化的方式提供相同的数据,这是一种替代视图。微格式或任何其他本土标准都可以有效地用于增强应用程序。

只要元素以标准方式构建,我就可以在所有应用程序中构建可重用代码的共享库,处理常见的数据项,例如姓名、地址、联系方式、电话号码等,以增强所有应用程序。例如,自动将地址链接到 Google 地图,或者链接电话号码以在移动设备上动态使用本机协议(例如 tel:)以及我可以做的各种其他增强功能。

HTML5 defines various semantic tags to mark your data:

It also allows for custom data attributes starting with "data-" within elements.

There is support for microdata which is based on microformats to provide more semantic structure to individual and groups of elements.

And to answer your main question:

No, I don't microformats because I didn't see the advantages until I gave your question a serious thought. I am using the newer HTML5 elements such as time, and custom data attributes, but not microformats because the data was already structured on the backend, and for more structured and semantic access, I'd would've used RSS feeds with specific extensions and include a link to the feed within the document itself.

That said, here's why I still support microformats and believe they are awesome and will most likely start using it in the very near future. For me, it serves a very specific purpose and has to do with programmatic access to the elements within my web applications. RSS and Atom feeds provide the same data in a very structured manner, but it's an alternative view. Microformats, or any other homegrown standards can be used effectively to enhance applications.

As long as the elements are structured in a standard manner, I can build upon a shared library of reusable code across all applications that deals with commonly occurring data items such as names, addresses, contact details, telephone numbers, etc. to enhance all applications. For example, automatically linking addresses to Google Maps, or linkifying telephone numbers to use a native protocol such as tel: on the fly for mobile devices and various other enhancements that I can do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文