attribute 와 property 의 차이_HTML

miin·2022년 1월 6일
0

HTML / CSS

목록 보기
17/28
post-thumbnail

attribute(속성)

html 문서에서 요소에 추가적인 정보를 넣을 때 사용되는 요소이다
ex)
< div class= ‘my-class’>< /div>
div -> element(요소)
class -> property || attribute(속성)
‘my-class’ -> class attribute의 value(값)

property(특성)

html DOM 안에서 attribute를 가리키는(혹은 대신하는)표현 이다
html 문서 안에서는 class가 attribute를 의미하지만,
html DOM 안에서는 property를 의미한다

attribute와 property를 구분하는 차이

  • attribute는 html document/file안에서의 정적인(바뀌지 않는)속성 그 자체를 의미하고,
    property는 html DOM트리 안에서 동적인(바뀌는) 속성(또는 그 값)을 의미한다

    ex1)
    체크박스 -> 유저가 체크박스에 체크를 하면
    속성의 상태는 변하지 않지만 특성의 상태는 checked로 변한다
    ex2)
    해당 DOM 값이 바뀜에 따라 특성도 바뀐다

0개의 댓글