⭐ CSS 문법

📌 기본 형태

h1 {
	color: red;
	font-size: 12px;
}

p {
	color: black;
}

📌 주석

/* 한 줄 주석 */

/*
여러
줄을
차지하는
주석
*/

/*
span {
	color: blue;
	font-size: 1.5em;
}
*/

⭐ CSS를 적용하는 방법

  1. 내부 스타일 (embedded)
  1. 인라인 스타일 (inline)
  2. 외부 스타일 (external)
  1. 내부 스타일 (embedded)

    <!DOCTYPE html>
    <html>
      <head>
        <style>
          h1 {
            color: red;
          }
        </style>
        <title>CSS</title>
      </head>
      <body>
        <h1>Welcome!</h1>
      </body>
    </html>
    
  2. 인라인 스타일 (inline)

    <body>
    	<h1 style="color:red">Welcome!</h1>
    </body>
    
  3. 외부 스타일 (external)

    <!DOCTYPE html>
    <html>
      <head>
        <title>CSS</title>
        <link rel="stylesheet" href="style/main.css" />
      </head>
      <body>
        <h1>Welcome!</h1>
      </body>
    </html>
    

⭐ 캐스캐이딩 원칙

  1. 스타일 우선순위
  1. 스타일 상속
  1. 스타일 우선순위

  2. 스타일 상속

⭐ CSS 선택자

▫️ 주요 선택자

📌 Type Selector

h2 {
	color: purple;
}

📌 ID Selector

#welcome-tilte {
	color: green;
}

📌 Class Selector

.blue {
	color: blue;
}

▫️ 속성 선택자

<!DOCTYPE html>
<html>
  <head>
    <title>CSS</title>
    <link rel="stylesheet" href="style/main.css" />
  </head>
  <body>
    <ul>
      <li>
        <a href="<http://example.com>" target="_blink">
          Example Link (com/http)
        </a>
      </li>
      <li>
        <a href="<http://example.org>" target="_blink">
          Example Link (org/http)
        </a>
      </li>
      <li>
        <a href="<https://example.com>">
          Example Link (com/https)
        </a>
      </li>
      <li>
        <a href="<https://example.org>">
          Example Link (org/https)
        </a>
      </li>
    </ul>
  </body>
</html>

📌 [attr]

a[target] {
	color: hotpink;
}

📌 [attr=value]

a[href="<https://example.org>"] {
	color: indigo;
}

📌 [attr^=value]

a[href^="https://"] {
	font-style: italic;
}

📌 [attr$=value]

a[href$=".com"] {
	color: silver;
}

📌 [attr*=value]

a[href*="example"] {
	color: sienna;
}

▫️ 가상클래스 선택자

▫️ 가상요소 선택자

⭐ float