Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

Using data-* attributes is actually part of the HTML5 standard.

Custom data attributes are intended to store custom data private to the page or application, for which there are no more appropriate attributes or elements.

These attributes are not intended for use by software that is independent of the site that uses the attributes.

(emphasis mine)

In my opinion, I like to keep behavior separate from style, so I lean towards using data-* attributes. A problem arises when you attach CSS styles to those custom attributes, though I must admit that some styling is OK (for instance, showing or hiding elements). If you want a data-ui=child element styled a certain way, add a class attribute to it to maintain your separation of style and behavior.

My only piece of advice when using data attributes is to "namespace" them such that you have data-ui and more specific or related attributes are data-ui-something where each data attribute your view framework uses is prefixed with data-ui. This helps prevent naming collisions with other people's code.

Using data-* attributes is actually part of the HTML5 standard.

Custom data attributes are intended to store custom data private to the page or application, for which there are no more appropriate attributes or elements.

These attributes are not intended for use by software that is independent of the site that uses the attributes.

(emphasis mine)

In my opinion, I like to keep behavior separate from style, so I lean towards using data-* attributes. A problem arises when you attach CSS styles to those custom attributes, though I must admit that some styling is OK (for instance, showing or hiding elements). If you want a data-ui=child element styled a certain way, add a class attribute to it to maintain your separation of style and behavior.

My only piece of advice when using data attributes is to "namespace" them such that you have data-ui and more specific or related attributes are data-ui-something where each data attribute your view framework uses is prefixed with data-ui. This helps prevent naming collisions with other people's code.

Using data-* attributes is actually part of the HTML5 standard.

Custom data attributes are intended to store custom data private to the page or application, for which there are no more appropriate attributes or elements.

These attributes are not intended for use by software that is independent of the site that uses the attributes.

(emphasis mine)

In my opinion, I like to keep behavior separate from style, so I lean towards using data-* attributes. A problem arises when you attach CSS styles to those custom attributes, though I must admit that some styling is OK (for instance, showing or hiding elements). If you want a data-ui=child element styled a certain way, add a class attribute to it to maintain your separation of style and behavior.

My only piece of advice when using data attributes is to "namespace" them such that you have data-ui and more specific or related attributes are data-ui-something where each data attribute your view framework uses is prefixed with data-ui. This helps prevent naming collisions with other people's code.

Source Link

Using data-* attributes is actually part of the HTML5 standard.

Custom data attributes are intended to store custom data private to the page or application, for which there are no more appropriate attributes or elements.

These attributes are not intended for use by software that is independent of the site that uses the attributes.

(emphasis mine)

In my opinion, I like to keep behavior separate from style, so I lean towards using data-* attributes. A problem arises when you attach CSS styles to those custom attributes, though I must admit that some styling is OK (for instance, showing or hiding elements). If you want a data-ui=child element styled a certain way, add a class attribute to it to maintain your separation of style and behavior.

My only piece of advice when using data attributes is to "namespace" them such that you have data-ui and more specific or related attributes are data-ui-something where each data attribute your view framework uses is prefixed with data-ui. This helps prevent naming collisions with other people's code.

lang-css

AltStyle によって変換されたページ (->オリジナル) /