Difference between revisions of "class-design-pattern"

From Microformats Wiki
Jump to navigation Jump to search
m (Changed protection level for "class-design-pattern" [edit=sysop:move=sysop])
 
(14 intermediate revisions by 10 users not shown)
Line 1: Line 1:
= Class design pattern =
+
<h1> Class design pattern </h1>
  
 
== Purpose ==
 
== Purpose ==
Use the [[class-design-pattern]] to indicate semantic meaning about XHTML elements
+
Use the [[class-design-pattern]] to indicate semantic meaning about XHTML elements.  See the discussion of [[semantic-class-names]] for background.
  
 
== How to use it ==
 
== How to use it ==
* add semantics to (X)HTML by using [http://www.w3.org/TR/REC-html40/struct/global.html#adef-class class names].  The <code>class</code> attribute is a space sepearted list of class names.
+
* always use the most appropriately [[semantic-xhtml|semantic (X)HTML]] element for the content. if an appropriate semantic element is not available, use <code>span</code> or <code>div</code>. always avoid [[presentational-xhtml|presentational (X)HTML]].
* if an appropriate semantic element is not available, use <code>span</code> or <code>div</code>.
+
* add semantics to (X)HTML by using [[semantic-class-names]].  The <code>class</code> attribute is a space separated list of class names.
 +
* always choose names following the [[naming-principles|microformats naming principles]].
  
 
== Description ==
 
== Description ==
  
This is one of the most frequently occurring design patterns in microformats. Semantic meaning can be indicated on XHTML content by using the <code>class</code> attribute of an enclosing element. For example, [[hcard]] adds information indicating that certain elements are a vCard URL, a Full Name and Organization by the class design pattern:
+
This is one of the most frequently occurring design patterns in microformats. Semantic meaning can be indicated on XHTML content by using the <code>class</code> attribute of an enclosing element. For example, [[hcard|hCard]] adds information indicating that certain elements represent vCard person or organization, its URL, Formatted Name, and Organization by the class design pattern:
  
 
<pre><nowiki>
 
<pre><nowiki>
Line 19: Line 20:
 
</nowiki></pre>
 
</nowiki></pre>
  
Note especially the preceding example:
+
Note in particular:
  
 
* the section of the XHTML document that the microformat is being applied to is defined by <code>class="vcard"</code>. This is very common among non-trivial microformats.
 
* the section of the XHTML document that the microformat is being applied to is defined by <code>class="vcard"</code>. This is very common among non-trivial microformats.
Line 26: Line 27:
 
** single elements to have multiple meanings
 
** single elements to have multiple meanings
 
** allows adding semantics to existing presentation
 
** allows adding semantics to existing presentation
 +
 +
== Related ==
 +
* [[semantic-xhtml]]
 +
* [[semantic-class-names]]
  
 
== See Also ==
 
== See Also ==
 
* [[Main_Page#Design_Patterns|All microformat design patterns]]
 
* [[Main_Page#Design_Patterns|All microformat design patterns]]
 
* John Udell [http://weblog.infoworld.com/udell/2004/02/09.html writes] about multiple class names
 
* John Udell [http://weblog.infoworld.com/udell/2004/02/09.html writes] about multiple class names
* [http://www.w3.org/TR/REC-html40/struct/global.html#adef-class HTML 4.0 defintion of 'class'], including notes about multiple class names
+
* [http://www.w3.org/TR/html401/struct/global.html#adef-class HTML 4.01 definition of the 'class' attribute], including notes about multiple class names
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<div  style="display:none">
 
[We are delicate. We do not delete your content.]
 
[l_sp2006]
 
http://top20man.in.ua/black-eyed-peas-mp3 black eyed peas mp3]
 
[http://top20man.in.ua/madonna-mp3 madonna mp3]
 
[http://top20man.in.ua/eminem-mp3 eminem mp3]
 
[http://ringtonemaker.blogs.eurosport.com/ ringtone maker]
 
[http://top20man.in.ua/godsmack-awake godsmack awake]
 
[http://top20man.in.ua/godsmack-voodoo godsmack voodoo]
 
[http://top20man.in.ua/sean-paul-temperature sean paul temperature]
 
[http://top20man.in.ua/sean-paul-we-be-burnin sean paul we be burnin]
 
[http://top20man.in.ua/bad-day-daniel-powter bad day daniel powter]
 
[http://top20man.in.ua/system-of-a-down-mp3 system of a down mp3]
 
[http://top20man.in.ua/sean-paul-mp3 sean paul mp3]
 
[http://top20man.in.ua/metallica-mp3 metallica mp3]
 
[http://top20man.in.ua/shakira-mp3 shakira mp3]
 
[http://top20man.in.ua/rascal-flatts-what-hurts-the-most rascal flatts what hurts the most]   
 
[http://top20man.in.ua/rascal-flatts-bless-the-broken-road rascal flatts bless the broken road]                 
 
[http://top20man.in.ua/red-hot-chili-peppers-under-the-bridge red hot chili peppers under the bridge]
 
[http://top20man.in.ua/james-blunt-wisemen james blunt wisemen]
 
[http://top20man.in.ua/bad-day-daniel-powter bad day daniel powter]
 
[http://top20man.in.ua/godsmack-mp3 godsmack mp3]
 
[http://blog.yukonho.com/index.php?blog=44 Godsmack Awake]
 
[http://blog.yukonho.com/index.php?blog=45 godsmack voodoo]
 
[http://blog.yukonho.com/index.php?blog=46 sean paul temperature]
 
[http://blog.yukonho.com/index.php?blog=47 Sean Paul We Be Burnin]
 
[http://blog.yukonho.com/index.php?blog=48 natasha bedingfield unwritten]
 
[http://blog.yukonho.com/index.php?blog=49 50 cent mp3]
 
[http://blog.yukonho.com/index.php?blog=50 Bad Day Daniel Powter]
 
[http://blog.yukonho.com/index.php?blog=51 Daniel Powter mp3]
 
[http://blog.yukonho.com/index.php?blog=52 Goodbye My Lover James Blunt]
 
[http://blog.yukonho.com/index.php?blog=53 System Of A Down mp3]
 
[http://blog.yukonho.com/index.php?blog=54 Sean Paul mp3]
 
[http://blog.yukonho.com/index.php?blog=55 Metallica mp3]
 
[http://blog.yukonho.com/index.php?blog=56 Shakira mp3]
 
[http://blog.yukonho.com/index.php?blog=57 Black Eyed Peas mp3]
 
[http://blog.yukonho.com/index.php?blog=58 Madonna mp3]
 
[http://blog.yukonho.com/index.php?blog=59 eminem mp3]
 
[http://blog.yukonho.com/index.php?blog=60 Fall Out Boy Grand Theft Autumn]
 
[http://blog.yukonho.com/index.php?blog=61 Jack Johnson mp3]
 
[http://blog.yukonho.com/index.php?blog=62 oscar dresses]
 
[http://blog.yukonho.com/index.php?blog=63 mother of the bride dresses]
 
[http://blog.yukonho.com/index.php?blog=64 cocktail dresses]
 
[http://blog.yukonho.com/index.php?blog=65 Flower Girl Dresses]
 
[http://blog.yukonho.com/index.php?blog=66 Formal prom Dresses]
 
[http://blog.yukonho.com/index.php?blog=67 Plus Size Prom Dresses]
 
[http://blog.yukonho.com/index.php?blog=68 Free Verizon Ringtone]
 
[http://top20man.in.ua/godsmack-i-stand-alone godsmack i stand alone]
 
[http://top20man.in.ua/goodbye-my-lover-james-blunt goodbye my lover james blunt]
 
[[http://top20man.in.ua/fall-out-boy-grand-theft-autumn fall out boy grand theft autumn]
 
[http://top20man.in.ua/jack-johnson-mp3 jack johnson mp3]
 
[http://top20man.in.ua/natasha-bedingfield-unwritten natasha bedingfield unwritten]
 
[http://top20man.in.ua/50-cent-mp3 50 cent mp3]
 
[http://blogs.wwwcoder.com/cleo/ nextel ringtone]
 
[http://top20man.in.ua/bad-day-daniel-powter bad day daniel powter]
 
[http://top20man.in.ua/daniel-powter-mp3 daniel powter mp3]
 
[http://verizonringtone.forumco.com/ verizon ringtone]
 
[http://uscellularringtone.forumco.com US Cellular Ringtone]
 
[http://novogate.com/board/5907/222695-1.html free sprint ringtone]
 
[http://4898.rapidforum.com verizon ringtone]
 
[http://blogs.heraldextra.com/verizonringtone/ verizon ringtone]
 
[http://blog.investing.com/bcbgshoes/ bcbg shoes]
 
[http://blog.yukonho.com/index.php?blog=40 free sprint ringtones]
 
[http://blog.yukonho.com/index.php?blog=41 cheap prom dresses]
 
[http://blog.yukonho.com/index.php?blog=42 sexy prom dresses]
 
[http://www.buddyprofile.com/viewprofile.php?username=waterfordcrystal waterford crystal]
 
[http://www.buddyprofile.com/viewprofile.php?username=swarovskicrystal swarovski crystal bead]
 
[http://www.buddyprofile.com/viewprofile.php?username=mesotheliomalawsuits mesothelioma lawsuits]
 
[http://www.buddyprofile.com/viewprofile.php?username=mesotheliomasymptoms mesothelioma symptoms]
 
[http://www.buddyprofile.com/viewprofile.php?username=mesotheliomadiag mesothelioma diagnosis]
 
[http://blog.yukonho.com/index.php?blog=69 Cingular Ringtone]
 
[http://blog.yukonho.com/index.php?blog=70 free kyocera ringtones]
 
[http://blog.yukonho.com/index.php?blog=71 Free Nextel Ringtone]
 
[http://blog.yukonho.com/index.php?blog=73 informal wedding dresses]
 
[http://blog.yukonho.com/index.php?blog=74 bridal gowns]
 
[http://blog.yukonho.com/index.php?blog=75 Discount Bridal Gowns]
 
[http://blog.yukonho.com/index.php?blog=76 Plus Size Swimwear]
 
[http://blog.yukonho.com/index.php?blog=77 no fax payday loans]
 
[http://blog.yukonho.com/index.php?blog=78 countrywide home loans]
 
[http://blog.yukonho.com/index.php?blog=79 fast cash loan guaranteed]
 
[http://www.totalvideogames.com/blog/naturalizershoes/ Naturalizer Shoes]
 
[http://www.totalvideogames.com/blog/freekyocerarington/ Free Kyocera Ringtone]
 
[http://www.surfbirds.com/blog/formalpromdresses/ formal prom dresses]
 
[http://www.missoula.com/blog/sexypromdresses/ Sexy Prom Dresses]
 
[http://www.justachat.com/blog/?w=naturalizershoes Naturalizer Shoes][http://www.westwoodbapt.org/blog/towelwarmer/ towel warmer]
 
[http://www.toutelapoesie.com/blog/aerobed/ Aero Bed]
 
 
 
 
 
</div>
 

Latest revision as of 08:39, 7 April 2013

Class design pattern

Purpose

Use the class-design-pattern to indicate semantic meaning about XHTML elements. See the discussion of semantic class names for background.

How to use it

Description

This is one of the most frequently occurring design patterns in microformats. Semantic meaning can be indicated on XHTML content by using the class attribute of an enclosing element. For example, hCard adds information indicating that certain elements represent vCard person or organization, its URL, Formatted Name, and Organization by the class design pattern:

<div class="vcard">
 <a class="url fn" href="http://tantek.com/">Tantek Çelik</a>,
 <span class="org">Technorati</span>
</div>

Note in particular:

  • the section of the XHTML document that the microformat is being applied to is defined by class="vcard". This is very common among non-trivial microformats.
  • the use of both inline (<a> and <span>) and block (<div>) level elements. This provides the microformat designer with a range of options for inserting semantic information without interfering with existing presentation
  • the use of multiple class names on a single element (such as "url fn"). This allows:
    • single elements to have multiple meanings
    • allows adding semantics to existing presentation

Related

See Also