What's the difference between an id and a class?

前端 未结 17 2527
长情又很酷
长情又很酷 2020-11-22 01:55

What\'s the difference between

and
when it comes to CSS? Is it alright to use
<
17条回答
  •  不要未来只要你来
    2020-11-22 02:26

    id and class are two Global / Standard HTML attribute (The global attributes below can be used on any HTML element.)

    class Specifies one or more classnames for an element (refers to a class in a style sheet)

    id Specifies a unique id for an element

    The id attributes gives an element document-wide unique identifier where the class attribute provides a way of classifying similar elements.

    The id attribute value must be unique across the HTML page where class attribute can be reused where ever you want to apply the same properties

提交回复
热议问题