html5 - Semantics of class vs ID in reusable templates -
i'm working on online store. i've learned little php , i'm using single template file conditional includes , such rather building separate product pages (no database yet though, still learning!).
so have section
s exist once per instance of template (ie once per page) such section id="product_image"
. identified id
. on template reused bunch of times think class
more semantically appropriate? (yes know there's no functional/technical need switch class
)
an id
singular. there can 1 of same id on page, , element may have 1 id attribute.
so if component gets reused, id must different between reuses (perhaps sort of database primary key, or similar).
a class name describes elements semantically, i.e. section what? widget? calendar? featured articles? that's class name for.
personally, use class names, , use ids if want link-scroll functionality. classes, ids are, more flexible.
Comments
Post a Comment