Front-End/HTML

[HTML] 10. ๊ณต๊ฐ„ ๋ถ„ํ•  ํƒœ๊ทธ ( div, span, table ...)

Bigone17 2021. 12. 23. 14:00

๐ŸŸก 1. ์›นํŽ˜์ด์ง€ ๊ณต๊ฐ„ ๋ถ„ํ• 

 - ์ง€๊ธˆ๊นŒ์ง€ HTML์„ ๊ณต๋ถ€ํ•œ ์ด์œ ๋Š” ์›น์‚ฌ์ดํŠธ๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ ๊ณต๋ถ€๋ฅผ ํ–ˆ๋Š”๋ฐ, ์›น์‚ฌ์ดํŠธ๋ฅผ ์ž˜ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ดˆ๋ฐ˜ ์„ค๊ณ„๋ถ€ํ„ฐ ์ž˜ํ•ด์•ผ ์ฐจํ›„์— ์ˆ˜์ •ํ•  ์ผ์ด ๋งŽ์ด ์•ˆ ์ƒ๊น๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ „์ฒด์ ์ธ ํฐ ํ‹€ ์ฆ‰ ๋ ˆ์ด์•„์›ƒ์„ ์ž˜ ์„ค๊ณ„ํ•˜๊ณ  ํ™”๋ฉด ๋ถ„ํ• ์„ ์ž˜ํ•ด์•ผ ๋ฉ๋‹ˆ๋‹ค. (๊ฑด๋ฌผ์„ ์ง“๊ธฐ ์ „์— ๋„๋ฉด์„ ์ž˜ ๋งŒ๋“ค์–ด์•ผ ๋˜๋Š” ๊ฑฐ์ฒ˜๋Ÿผ)

์ถœ์ฒ˜ :https://poiemaweb.com/html5-tag-structure

- ๋ ˆ์ด์•„์›ƒ์„ ๊ตฌ์„ฑํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๊ณต๊ฐ„์„ ๋ถ„ํ• ์„ ํ•˜๋Š”๋ฐ, ์œ„ ์‚ฌ์ง„์— ๋‚˜์˜จ ์˜ˆ์‹œ๊ฐ€ ๋ณดํŽธ์ ์ธ ๋ถ„ํ•  ์ข…๋ฅ˜์ž…๋‹ˆ๋‹ค. ์•„๋ž˜ ์‚ฌ์ง„์€ ์‹ค์ œ ์šด์˜๋˜๊ณ  ์žˆ๋Š” ์›น์‚ฌ์ดํŠธ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค.

์˜ˆ์‹œ ์ฐพ๋‹ค๊ฐ€ ํฌ๊ธฐ... ์˜ˆ์‹œ ์ฐพ๋‹ค๊ฐ€ ํฌ๊ธฐ...

 

 

๐ŸŸก 2. ๊ณต๊ฐ„ ๋ถ„ํ•  ํƒœ๊ทธ

- ๊ณต๊ฐ„์„ ๋ถ„ํ• ํ•˜๋Š” ํƒœ๊ทธ๋“ค๋กœ๋Š” div, span, table ๋“ฑ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ณผ๊ฑฐ ์›น์‚ฌ์ดํŠธ์—์„œ๋Š” ์ฃผ๋กœ table๋กœ ๊ณต๊ฐ„ ๋ถ„ํ• ์„ ๋งŽ์ด ํ–ˆ์ง€๋งŒ, ์š”์ฆ˜ ๋“ค์–ด์„œ๋Š” div ํƒœ๊ทธ๋ฅผ ์ด์šฉํ•ด์„œ ๋ ˆ์ด์•„์›ƒ์„ ๊ตฌ์„ฑํ•˜๋Š” ๊ฒŒ ๋ณดํŽธ์ ์ž…๋‹ˆ๋‹ค.
 ๊ทธ๋Ÿฐ๋ฐ div ํƒœ๊ทธ๋Š” ๊ทธ๋ƒฅ ํ•˜๋‚˜์˜ ๊ณต๊ฐ„์ด๋ผ๋Š” ์˜๋ฏธ๋งŒ์„ ๊ฐ€์ง€๊ณ  ์žˆ์–ด์„œ, ์ •ํ™•์ด ์ด div๊ฐ€ ์–ด๋–ค ๋ถ€๋ถ„์„ ๋‚˜ํƒ€๋‚ด๊ณ  ์–ด๋–ค ์˜๋ฏธ์ธ์ง€ ์ •ํ™•ํ•˜๊ฒŒ ์•Œ ์ˆ˜ ์—†๊ธฐ ๋•Œ๋ฌธ์— HTML5์—์„œ ๋ ˆ์ด์•„์›ƒ ๊ด€๋ จ ์ƒˆ๋กœ์šด ํƒœ๊ทธ๋“ค์ด ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

์ถœ์ฒ˜ :https://blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=ndb796&logNo=220703223472

 

ํƒœ๊ทธ ์„ค๋ช…
header ์›น์‚ฌ์ดํŠธ์˜ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋“ค์„ ๋‹ด๊ณ  ์žˆ๊ณ , ํŽ˜์ด์ง€์˜ ํƒ€์ดํ‹€์„ ๋ณด์—ฌ์ฃผ๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค.
nav ๋„ค์ด๊ฒŒ์ดํ„ฐ๋ฅผ ์˜๋ฏธํ•˜๊ณ , ํŽ˜์ด์ง€ ์ด๋™์„ ํ•  ๋•Œ ์ด์šฉํ•ฉ๋‹ˆ๋‹ค.
aside ๋ณธ๋ฌธ ์˜†์— ์กด์žฌํ•˜๊ณ  ๋ณธ๋ฌธ๊ณผ๋Š” ์—ฐ๊ด€์ด ์—†๋Š” ๋‚ด์šฉ์ด ๋งŽ๊ณ , ์ฃผ๋กœ ๊ด‘๊ณ ๋‚˜ ์นดํ…Œ๊ณ ๋ฆฌ ๋ชฉ๋ก์„ ํ‘œ์‹œ ํ•ฉ๋‹ˆ๋‹ค.
section ๋ณธ๋ฌธ(article)์„ ์—ฌ๋Ÿฌ๊ฐœ ํฌํ•จํ•˜๊ณ  ์žˆ๋Š” ๊ณต๊ฐ„์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.
article ๋ณธ๋ฌธ์˜ ์ฃผ๋‚ด์šฉ์ด ๋“ค์–ด๊ฐ€๋Š” ๊ณต๊ฐ„์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.
footer ํ‘ธํ„ฐ๋ฅผ ์˜๋ฏธํ•˜๊ณ , ์ฃผ๋กœ ์›น์‚ฌ์ดํŠธ์˜ ์นดํ”ผ๋ผ์ดํ„ฐ(์ €์ž‘๊ถŒํ‘œ์‹œ), ๋Œ€ํ‘œ์ž, ์ด๋ฉ”์ผ๋“ฑ์„ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

 

 

 

๐ŸŸก 3. div ํƒœ๊ทธ

- div ํƒœ๊ทธ๋Š” Division์˜ ์•ฝ์ž๋กœ ์›น์‚ฌ์ดํŠธ์˜ ๋ ˆ์ด์•„์›ƒ์„ ๋งŒ๋“ค ๋•Œ ์ฃผ๋กœ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. 
- div ํƒœ๊ทธ์—๋Š” ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ์†์„ฑ๋“ค์ด ์žˆ๋Š”๋ฐ ์ฃผ๋กœ style ์†์„ฑ์„ ์ด์šฉ์„ ๋งŽ์ด ํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜ ํ‘œ๋Š” style ์†์„ฑ ์•ˆ์— ๋“ค์–ด๊ฐˆ ์ˆ˜ ์žˆ๋Š” ์†์„ฑ๋“ค์˜ ์ข…๋ฅ˜ ๋ฐ ์„ค๋ช…์ž…๋‹ˆ๋‹ค. ํ‘œ ์ด์™ธ์—๋„ ๋งŽ์€ ์†์„ฑ๋“ค์ด ์žˆ์Šต๋‹ˆ๋‹ค.

์†์„ฑ ์„ค๋ช…
width div ํƒœ๊ทธ์˜ ๊ฐ€๋กœ ํฌ๊ธฐ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
height div ํƒœ๊ทธ์˜ ์„ธ๋กœ ํฌ๊ธฐ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
border div ํƒœ๊ทธ์˜ ํ…Œ๋‘๋ฆฌ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
background-color div ํƒœ๊ทธ์˜ ๋ฐฐ๊ฒฝ ์ƒ‰์ƒ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
float div ํƒœ๊ทธ์˜ ์›น์‚ฌ์ดํŠธ ๊ธฐ์ค€ ์œ„์น˜๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. (์ •๋ ฌ)
margin div ํƒœ๊ทธ์˜ ์—ฌ๋ฐฑ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

 

style : ์†์„ฑ ์ฝ”๋“œ ๊ฒฐ๊ณผ
width
// width : 100px
<
div style="width: 100px; border: 1px solid tomato;">
        <h1>1</h1>
</div>
// width : 200px
<div style="width: 200px; border: 1px solid tomato;">
        <h1>1</h1>
</div>
height
// height : 100px
<
div style="height: 100px; width: 100px; border: 1px solid tomato;">
        <h1>1</h1>
</div>
// height : 200px
<div style="height: 200px; width: 100px; border: 1px solid tomato;">
        <h1>1</h1>
</div>
border
// ๋‘๊ป˜ 1px, ์‹ค์„ , ํ† ๋งˆํ† ์ƒ‰
<
div style="height: 100px; width: 100px; border: 1px solid tomato;">
        <h1>1</h1>
</div>
<br>
// ๋‘๊ป˜ 3px, ์ ์„ , ํ•˜๋Š˜์ƒ‰
<div style="height: 100px; width: 100px; border: 3px dotted skyblue;">
        <h1>1</h1>
</div>
background-color
// ๋ฐฐ๊ฒฝ์ƒ‰ ํ•˜๋Š˜์ƒ‰
<
div style="height: 100px; width: 100px; background-color: skyblue;">
        <h1>1</h1>
      </div>
<br>
// ๋ฐฐ๊ฒฝ์ƒ‰ teal์ƒ‰
<div style="height: 100px; width: 100px; background-color: teal;">
        <h1>1</h1>
</div>
float
// ์™ผ์ชฝ ์ •๋ ฌ
<
div style="height: 100px; width: 100px; background-color: skyblue; float: left;">
        <h1>1</h1>
</div>
// ์˜ค๋ฅธ์ชฝ ์ •๋ ฌ
<div style="height: 100px; width: 100px; background-color: teal; float: right;">
        <h1>1</h1>
</div>
margin
// margin ์ด ์—†์Œ
<
div style="height: 100px; width: 100px; background-color: skyblue;">
        <h1>1</h1>
</div>
// ์œ„,์•„๋ž˜, ์™ผ์ชฝ, ์˜ค๋ฅธ์ชฝ ๋งˆ์ง„ 100px
<div style="height: 100px; width: 100px; background-color: teal; margin: 100px; border: 1px solid black">
        <h1>1</h1>
</div>
// ์‚ด๊ตฌ์ƒ‰ ๋ฐ”ํƒ•์ด ๋งˆ์ง„์˜ ๋ฒ”์œ„๊ฐ€ ๋œ๋‹ค.
// ๋นจ๊ฐ„์ƒ‰ํ…Œ๋‘๋ฆฌ, margin ๊ธ€์”จ, ์‚ด๊ตฌ์ƒ‰์€ ๊ทธ๋ฆผํŒ์—์„œ ์ž„์˜๋กœ ๋„ฃ์€ ๊ฒƒ์œผ๋กœ ์ฝ”๋“œ ์ž‘์„ฑ์‹œ ๋˜‘๊ฐ™์ด ๋ณด์ด์ง€ ์•Š์„๊ฒƒ์ž„.

 

 

 

๐ŸŸก 4. span ํƒœ๊ทธ

 - span ํƒœ๊ทธ๋Š” div ํƒœ๊ทธ์™€ ๊ฐ™์ด ๊ณต๊ฐ„์„ ๋‚˜ํƒ€๋‚ด๋Š” ํƒœ๊ทธ์ธ๋ฐ, div์™€ ๋‹ค๋ฅธ ์ ์€ div๋Š” ์ค„ ๋ฐ”๊ฟˆ์ด ๋˜์ง€๋งŒ span์€ ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

<span style="background-color: blueviolet;">
	span1
</span>

span ํƒœ๊ทธ

span
<span>
        ์•ˆ๋…•ํ•˜์„ธ์š”
</span>
<span>
        ์ €๋Š” ๋น…์›์ž…๋‹ˆ๋‹ค.
</span>
div
<div>
        ์•ˆ๋…•ํ•˜์„ธ์š”
</div>
<div>
        ์ €๋Š” ๋น…์›์ž…๋‹ˆ๋‹ค.
</div>

 

- div๋Š” ํ™”๋ฉด์˜ ๊ฐ€๋กœ ์ „์ฒด๋ฅผ ์‚ฌ์šฉํ•˜๊ณ , span์€ ์ž์‹  ์•ˆ์— ์ฝ˜ํ…์ธ ๋งŒํผ๋งŒ ๊ณต๊ฐ„์„ ์ฐจ์ง€ํ•œ๋‹ค. 

<div>div</div>
<span>span</span>

 

 

๊ธด ๊ธ€ ์ฝ์–ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค :) 
ํ‹€๋ฆฐ ๋‚ด์šฉ์ด ์žˆ๊ฑฐ๋‚˜, ๋ง๋ถ™์ผ ๋‚ด์šฉ์ด ์žˆ๋‹ค๋ฉด ์–ธ์ œ๋“ ์ง€ ๋Œ“๊ธ€ ๋‹ฌ์•„์ฃผ์„ธ์š”!
์ œ ๊ธ€์ด ์กฐ๊ธˆ์ด๋‚˜๋งˆ ์ฝ์€ ์‹  ๋ถ„๋“ค์—๊ฒŒ ๋„์›€์ด ๋˜๋„๋ก ๋…ธ๋ ฅํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค
๋‹ค์Œ ํŽธ์— ๋ดฌ์š”~

728x90
๋ฐ˜์‘ํ˜•