⚫ CSS table

DayΒ·2022λ…„ 4μ›” 4일
0
post-thumbnail
post-custom-banner

πŸ“Š table

<table>, <tr>(table row), <td>(table data), <th>(table heading)

ν…Œμ΄λΈ”μ€ 항상 <table> νƒœκ·Έλ‘œ 감싸져 μžˆλ‹€.
 
  ν•œ 행을 μ‹œμž‘ν• λ•Œ <tr>(table row)둜 μ‹œμž‘
  각각의 셀은 <tr> νƒœκ·Έ μ•ˆμ— <td>(table data) νƒœκ·Έ μ‚¬μš©
<table>
    <tr>
      <td>Row 1, column 1</td>
      <td>Row 1, column 2</td>
    </tr>
    <tr>
      <td>Row 2, column 1</td>
      <td>Row 2, column 2</td>
    </tr>
  </table>

<table>
  <tr>
    <th></th>
    <th>Dog</th>
    <th>Cat</th>
  </tr>
  <tr>
    <th>μ’…</th>   
    <td>Canine</td>
    <td>Feline</td>
  </tr>
  <tr>
    <th>μ§–λŠ”μ†Œλ¦¬</th>
    <td>Bark</td>
    <td>Meow</td>
  </tr>
  <tr>
    <th>Immature</th>
    <td>Puppy</td>
    <td>Kitten</td>
  </tr>
</table>

<td> λŒ€μ‹  <th>(table heading) μ‚¬μš© 
css μ μš©ν• λ•ŒλŠ”, <table>νƒœκ·Έμ— class λΆ€μ—¬ν•˜κ³ λ‚˜μ„œ, style.css κ°€μ„œ
.border-table th, .border-table td {
  border: 1px solid black; 
}

🧢 병합

<rowspan> : ν–‰ 병합
<colspan> : μ—΄ 병합

<table class="border-table">
      <tr>
        <th></th>
        <th>λ‚΄μš©</th>
        <th>μž₯μ†Œ</th>
      </tr>
      <tr>
        <th>1μ‹œ</th>
        <td>HTMLμ΄λž€</td>
        <td>101호</td>
      </tr>
       <tr>
        <th>2μ‹œ</th>
        <td rowspan="2">HTMLμ‹€μŠ΅</td>
        <td>102호</td>
      </tr>
       <tr>
        <th>3μ‹œ</th>
        <td>103호</td>
      </tr>
      <tr>
        <th>4μ‹œ</th>
        <td>CSSλž€</td>
        <td>104호</td>
      </tr>
      <tr>
        <th>5μ‹œ</th>
        <td>CSSμ‹€μŠ΅</td>
        <td>104호</td>
      </tr>
      <tr>
        <th>6μ‹œ</th>
        <td colspan="2">μˆ˜μ—… μ—†μŠ΅λ‹ˆλ‹€.</td>
      </tr>
    </table>

ν…Œμ΄λΈ” μ „μ²΄λ‚˜ 각각의 td th에닀 클래슀 μ€˜μ„œ css 적용 κ°€λŠ₯

post-custom-banner

0개의 λŒ“κΈ€