HTML

4. HTML Attributes

okthatsimple 2024. 7. 7. 20:02

Attributes

  • 역할 : HTML element에 정보를 추가함. 모든 element는 attribute를 가질 수 있음.
  • 위치 : attribute 위치는 언제나 opening tag임.
  • 조건 : name="value" 형태로 작성.
  • 대표적으로 아래 attribute가 있음.
    • id
      • 고유 id를 element에 지정함.
      • styling, 자바스크립트 함수 인자로 사용
    • class
      • 여러 클래스를 지정 가능.
      • styling, CSS 적용 시 사용
    • src
      • 이미지, 음악, 동영상 등 자료의 URL을 설정
    • href
      • 연결된 자료의 URL을 명시, 보통 하이퍼링크에 사용.
  • 이 외에도 많은 태그들이 있다.
    • width="300px"
    • height="100px"
    • title="Hello"
    • style="font-size:20px"

id, class 예시

<!DOCTYPE html>
<html>

<head>
    <style>
        #blueid {
            color: white;
            background-color: blue;
        }

        .white {
            color: white;
        }

        .bluefont {
            background-color: blue;
        }
    </style>
</head>

<body>
    <p id="blueid">Blue!</p>
    <p class="white bluefont">Blue!</p>
</body>

</html>

'HTML' 카테고리의 다른 글

6. HTML Entities  (0) 2024.07.08
5. HTML Heading, Links, Images, Semantics  (0) 2024.07.07
3. HTML elements  (0) 2024.07.07
2. HTML 주석  (0) 2024.07.07
1. HTML 페이지 구조  (0) 2024.07.07