πŸ’»Coding/πŸ“’ CSS

CSS _μž‘μ„± μœ„μΉ˜μ™€ 연결방법

μŒμ€μ‘ 2021. 8. 25. 20:34
728x90
λ°˜μ‘ν˜•

CSS _μž‘μ„± μœ„μΉ˜μ™€ 연결방법

CSS
Q : CSSλŠ” 어디에 μž‘μ„±ν•΄μ•Όν• κΉŒμš”?

- "CSSλŠ” μΈλΌμΈμŠ€νƒ€μΌ / λ‚΄λΆ€μŠ€νƒ€μΌμ‹œνŠΈ / μ™ΈλΆ€μŠ€νƒ€μΌμ‹œνŠΈ λ‚˜λ‰©λ‹ˆλ‹€."

1). λ‚΄λΆ€ μŠ€νƒ€μΌμ‹œνŠΈ
γ„΄ html <head>~</head> μ˜μ—­μ— <style>~</style>둜 μž‘μ„±ν•˜λŠ” 방법

2). 인라인 μŠ€νƒ€μΌ μž‘μ„±ν•˜λŠ” 방법
γ„΄ html <style>νƒœκ·Έλ₯Ό μ‚¬μš©ν•΄ <body>μ•ˆμ— μž‘μ„±ν•œ νƒœκ·Έμ— μž‘μ„±ν•˜λŠ” 방법

3). μ™ΈλΆ€ μŠ€νƒ€μΌμ‹œνŠΈ μž‘μ„±ν•˜λŠ” 방법
γ„΄ μžλ°”μŠ€ν¬λ¦½νŠΈ νŒŒμΌμ„ μ™ΈλΆ€μ—μ„œ λ”°λ‘œ λ§Œλ“€μ–΄μ„œ, html νŒŒμΌμ— μ—°κ²°ν•˜λŠ” 방법
γ„΄ β€»μžλ°”μŠ€ν¬λ¦½νŠΈ νŒŒμΌμ„ λ§Œλ“œλŠ” ν™•μž₯μžλŠ” cssμž…λ‹ˆλ‹€.
γ„΄ 즉, λ¬Έμ„œ μ €μž₯μ‹œ νŒŒμΌμ΄λ¦„.css λΌκ³  μ €μž₯ν•΄μ£Όμ‹œλ©΄ λ©λ‹ˆλ‹€.

[파일 μ €μž₯ μ˜ˆμ‹œ]

파일λͺ….css

πŸ“Œ Q : cssλŠ” 어디에 μž‘μ„±ν•˜κ³ , μ™ΈλΆ€μ—μ„œ μž‘μ„±ν•œ νŒŒμΌμ€ 또 μ–΄λ–»κ²Œ λΆˆλŸ¬μ˜¬κΉŒμš”?

A : μΈλΌμΈμŠ€νƒ€μΌ / λ‚΄λΆ€μŠ€νƒ€μΌμ‹œνŠΈ / μ™ΈλΆ€μŠ€νƒ€μΌμ‹œνŠΈμ—°κ²°μ„ μ΄λ―Έμ§€λ‘œ ν•œλˆˆμ— ν™•μΈν•΄λ³ΌκΉŒμš”?🀩

 

[ htmlμ—μ„œ css μž‘μ„±]

css - μΈλΌμΈμŠ€νƒ€μΌ, λ‚΄λΆ€μŠ€νƒ€μΌμ‹œνŠΈ, μ™ΈλΆ€μŠ€νƒ€μΌμ‹œνŠΈ

 

였늘의 핡심!
γ„΄ 각 μœ„μΉ˜μ—μ„œ cssλ₯Ό μ–΄λ–»κ²Œ μž‘μ„±ν•˜λŠ”μ§€, 어디에 μž‘μ„±ν•  수 μžˆλŠ”μ§€ μ΄ν•΄ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€~

(↓μ•„λž˜μ˜ μ½”λ“œλ₯Ό λ³΅μ‚¬ν•΄μ„œ cssκ°€ 잘 μ μš©λ˜λŠ”μ§€ ν™•μΈν•΄λ³΄μ„Έμš”! )

 

1). λ‚΄λΆ€ μŠ€νƒ€μΌμ‹œνŠΈμ—μ„œ css μž‘μ„±ν•˜κΈ°

β–Ά <head> μ˜μ—­μ—μ„œ μž‘μ„±ν•˜κΈ°

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>css_</title>
    <style>
        h2 {color: red;}
    </style>
</head>
<body>
    <h2>hello css</h2>
</body>
</html>

 

[ μ‹€ν–‰ν™”λ©΄ ]

 

2). 인라인 μŠ€νƒ€μΌ μž‘μ„±ν•˜λŠ” 방법

β–Ά <body> μ˜μ—­μ—μ„œ μž‘μ„±ν•˜κΈ°

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>css_</title>
</head>
<body>
    <h2 style="color: red;">hello css</h2>
</body>
</html>

 

3). μ™ΈλΆ€ μŠ€νƒ€μΌμ‹œνŠΈ μž‘μ„±ν•˜λŠ” 방법

β–Ά css파일 λ”°λ‘œ λ§Œλ“€μ–΄μ„œ μž‘μ„±ν•˜κΈ°
γ„΄ λ¨Όμ €, basic.css νŒŒμΌμ„ ν•˜λ‚˜ λ§Œλ“€μ–΄μ€λ‹ˆλ‹€.
(파일 μƒˆλ‘œ λ§Œλ“€κΈ° : ctrl+n → 파일 이름은 영문으둜 ν™•μž₯μžλŠ” css둜 μ„€μ •ν•˜μ—¬ μ €μž₯ν•˜κΈ°: ex, basic.css )

β–Ά css νŒŒμΌμ— μž‘μ„±ν•˜κΈ°

h2 {color:red;}

β–Ά css 파일 html νŒŒμΌμ— μ—°κ²°ν•˜κΈ°

 

  • rel 은 HTML νŽ˜μ΄μ§€μ™€ 링크된 νŒŒμΌκ°„μ˜ 관계λ₯Ό 의미
  • href λŠ” CSS file 경둜λ₯Ό μ˜λ―Έν•¨
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>css_</title>
    <link rel="stylesheet" href="css/example.css">
</head>
<body>
    <h2>hello css</h2>
</body>
</html>
3개의 화면이 λͺ¨λ‘ λ˜‘κ°™μ΄ 보인닀면 잘 μž‘μ„±ν•˜μ‹ κ±°μ˜ˆμš”!
μ—¬λŸ¬λΆ„μ€ 이제 css의 μ†μ„±λ§Œ μ•Œλ©΄ λ‹€ κΎΈλ°€μˆ˜ 있게 λ˜μ—ˆμŠ΅λ‹ˆλ‹€!!πŸŽ‰πŸŽ‰πŸŽ‰

 

였늘의 css 끝~
728x90
λ°˜μ‘ν˜•