html - What are valid HTML5 custom tags? -


recently i've been reading how can make custom tags valid in html5 putting dash in name, i've been wondering actual rules / guidelines custom tags.

custom-tag
custom x
-custom ?
custom- ?

what want know if last 2 valid.


also, bonus, i'm kind of curious how custom attributes work.. far know:

<div my-attribute="demo"> x
<div data-my-attribute="demo">
<custom-tag my-attribute="demo">
<custom-tag data-my-attribute="demo">

but happens if i'm trying use existing global attributes, such title or class?

does css..

custom-tag.banana {     color: yellow; } 

target html?

<custom-tag class="banana">     test! </custom-tag> 

also, css should target above html whether or not global attributes work custom tags, correct?

custom-tag[class=banana] {     color: yellow; } 

finally, there rule/guideline stating should have "-" in name of custom attribute, custom tags? e.g. <div custom-tag="demo">. if there is, original question, work -customtag, , customtag-?

thanks help. :)

tl;dr: there no valid custom html5 tags.


i think may referring custom element working draft proposed web applications working group, describes this:

the custom element type identifies custom element interface , sequence of characters must match ncname production, must contain u+002d hyphen-minus character, , must not contain uppercase ascii letters. custom element type must not 1 of following values:

  • annotation-xml
  • color-profile
  • font-face
  • font-face-src
  • font-face-uri
  • font-face-format
  • font-face-name
  • missing-glyph

additionally, according html5 specification, html tag names can start ascii letters. if assume custom element proposal not propose changes html syntax specification, elements starting hyphens-minus character not valid html tag name. if combine custom element working draft proposal , html5 syntax specification says, can conclude <-custom> not well-formed html , cannot valid custom element because tag name not start ascii letter. on other hand, custom- both well-formed html , valid custom element.

note custom element working draft, not w3c recommendation. means custom elements not valid in html5. don't hopes either, lot of working drafts proposed in w3c never got anywhere (and reasons too, not of proposals good).

<rant>personally hope proposal got shot down. spent time reading proposal, looks proposal tried reinvent xml namespace , sgml poorly, , forgot html , semantic web supposed be. in case, html5 syntax allows authors use elements aren't specified in html5 specification, don't see need standardize how create custom elements further that. hope there people in html5 working group sane enough realize how bad proposal , vote proposal off. keep html5 closed author-defined custom modifications.</rant>

if want define own custom vocabularies, suggest should write xml application xhtml5, specifies how can define own custom elements xml namespaces. unlike html, xml designed extensible.


as question custom data attribute, the html5 specification says:

a custom data attribute attribute in no namespace name starts string "data-", has @ least 1 character after hyphen, xml-compatible, , contains no uppercase ascii letters.

so examples, these valid data-* attributes:

  • data-my-attribute

while these not:

  • my-attribute

as far can tell, custom elements working draft not specify additional syntactical requirement custom attributes on custom elements, nor explicitly permit using arbitrary non-data-* attributes , how custom attributes interacts existing html attributes, although can reasonably infer allowing custom attributes intent of proposal.


as question css, yes understood correctly, valid css selectors target custom elements. css can used style elements, not elements defined html, other markup languages svg, mathml, arbitrary xml vocabularies when using xhtml. css selectors specification not depend on html vocabulary in substantial way (although html used heavily in examples, it's people familiar with). reason css selector syntax can used refer elements in document, including custom elements aren't specified in html specification. styling custom tag works in major browsers today. can use arbitrary tag names, , select them selector expect, , css style them expect them be. there no requirement having hyphen-minus in tag name work.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -