Custom html tags — Is there a better way?

前端 未结 4 1244
迷失自我
迷失自我 2021-01-15 10:00

I am attempting to complete a browser plugin that will analyze text and mark it in some fashion.

Basically, let\'s say your browsing and you see this come across th

相关标签:
4条回答
  • 2021-01-15 10:29

    There’s really no guarantee that <fhwdgads> is never recognized as a tag with some special semantics or formatting. It might be improbable if you use a very messy tag name, but would you, really? People tend to use mnemonic names when they invent tags, and then there’s a real chance of clashing with tags in some current or future spec or browser.

    Moreover, some old versions of IE ignore unrecognized tags completely, e.g. do not let you style them. This can be avoided using document.createElement() once for each tag name, though.

    Using span or div is as such safe in practice. There is no reason to think that browsers have some fancy formatting for them by default. Just as we don’t stop using h1 even though it is theoretically possible that it will make the content pink and blinking. It’s impossible to be foolproof if you expect browser vendors to be totally crazy.

    Using classes is a different matter, though only in the sense that other style sheets play with the same class names as you. You might need to work in an environment where other author style sheets interfere with yours. But this just calls for caution; it does not make a span or div element with a class the wrong tool.

    0 讨论(0)
  • 2021-01-15 10:29

    You can use the <DIV> tag instead. Based from my "experience", the div element pretty much goes anywhere on the html hierarchy (inside <body> and not inside input tags). You must note the default styles though.

    0 讨论(0)
  • 2021-01-15 10:31

    I think that the using of custom html tags is not a bad way. Of course I can't promise that you have not any related technical problems with developing of your plugin. But Facebook did: http://developers.facebook.com/docs/reference/fbml/

    I don't know why it has been removed.

    You can also add your special namespace extention (like fb: for Facebook). Web 2.0 supports independence of data representation and user-defined tags: http://en.wikipedia.org/wiki/Web_2.0#Concepts

    0 讨论(0)
  • 2021-01-15 10:33

    A solution would be to define a CSS-class that first resets all style properties so you can start off with a clean slate.

    Another solution would be to use tags that are not used very often such as del, ins and blockquote

    0 讨论(0)
提交回复
热议问题