관리 메뉴

커리까지

CSS 수업 - 선택자의종류 본문

자바

CSS 수업 - 선택자의종류

목표는 커리 2021. 2. 5. 08:14
728x90
SMALL

CSS 수업 - 선택자의종류 1 : 아이디선택자

<head>
    <style>
        li{
            color:red;
            text-decoration:under-line;
        }
    </style>    
</head>
<body>

<ul>
    <li>html</li>
    <li id='select'>css</li>
    <li>css</li>
</ul>

</body>

태그선택자

<style>
  li{
     color:red;
     text-decoration:under-line;
  }
</style>    
  • li

ID선택자

<head>
    <style>
      li{
         color:red;
         text-decoration:under-line;
      }

        #select {
            font-size:100px;
        }
    </style>    
</head>
<body>
    <ul>
        <li>html</li>
        <li id='select'>css</li>
        <li>css</li>
    </ul>
</body>    
  • #select

  • id=' : html문법 , select는 html의 속성값

CSS 수업 - 선택자의종류 2 : 클래스선택자

클랙스 선택자

<head>
    <style>
      li{
         color:red;
         text-decoration:under-line;
      }

        #select {
            font-size:100px;
        }
        .deactive{
            text-decoratiob: line-through;
        }
    </style>
</head>    
<body>

    <h1 class='deactive'>
        야호
    </h1>
    <ul>
        <li class='deactive'>html</li>
        <li id='select'>css</li>
        <li class='deactive'>css</li>
    </ul>

</body>    
  • 왜 클래스일까?
  • 어떠한 대상을 관리하기 쉽도록 그룹핑한 것(class)
    • class는 중복가능
  • 하나 하나를 관리하기 위해 식별자를 주는데 이게 id
    • id는 중복불가
728x90
LIST