Where do you post your semantic information, html?

Well, I continue to nest semantic information about what the element means for the page logically in the class attribute

 <li class="phone-number">555-5555</li> 

This seems to work for this dual purpose — visual semantic information and a pointer to its style.

I'm not sure if this is the best idea, I'm trying to figure out if others have ways to do this.

I also started using hidden input:

 <li>555-5555 <input class="semantics" type="hidden" value="phone-number" /></li> 

inside the element, so with jQuery I can get additional information about the element using

 li.find( '.semantics' ).val() 

To get the semantics of elements from JavaScript

+4
source share
3 answers

I use semantics with guides and examples at microformats.org . What about style - you can use several classes for html elements. In jQuery you can use $('.phone-number').html() for your first example.

+3
source
  • Either try XML, or an XSLT example for presentation,
  • or HTML with custom DTD
  • or HTML 5 and data attribute (3.2.1 Semantics)
+2
source

It will depend on the semantics itself ... Usually identifiers and classes are enough for this purpose.

But adding markup like hidden margins for this purpose sounds like a terrible idea to me.

Perhaps if you shared your real needs, we could share a better way to do this.

0
source

Source: https://habr.com/ru/post/1310566/


All Articles