웹 프로그래밍/html

html attributes

jsleee 2023. 1. 3. 16:59

html 코드를 짤때 tag만으로는 부족한 경우가 많다

이에 tag에 부가적인 정보를 추가해주고 싶을때 attribute를 사용한다.

 

즉 attribute는 tag에 부가적인 정보를 추가해주는 용도로 사용된다. 

우선 코드를 먼저 보자.

    <!DOCTYPE html>
 <html>
    <head>

    </head>
    <body>
        <a href="http://www.google.com">go to google</a>
    </body>
 </html>

다음 코드에서 a(anchor)라는 태그 안에 href(hyperlink-reference)라는 attribute가 포함되어있다. 

href attribute는 브라우저에게 이동할 경로를 알려주는 역할을 한다.

 

이 외에도 id, class, style 등의 attribute들은 속해있는 tag에 추가적인 정보를 제공하는 역할을 한다.