Computer >> 컴퓨터 >  >> 프로그램 작성 >> HTML

HTML에서 테이블 헤더를 만드는 방법은 무엇입니까?


HTML에서 태그를 사용하여 테이블 헤더를 생성합니다. HTML 태그는 테이블에 헤더를 추가하는 데 사용됩니다. thead 태그는 tbody 태그 및 tfoot 태그와 함께 테이블의 각 부분(header, footer, body)을 결정하는 데 사용됩니다.

HTML 태그는 다음과 같은 추가 속성도 지원합니다. -

속성

설명
정렬
오른쪽
왼쪽
센터
신이 옳다고 하다

사용 중단 - 시각적 정렬.
문자
문자
사용 중단 − 텍스트를 정렬할 문자를 지정합니다. align ="char"일 때 사용
문자열
픽셀 또는 %
사용 중단 - char 속성으로 지정된 첫 번째 문자에 대한 정렬 오프셋(픽셀 또는 백분율 값)을 지정합니다. align ="char"일 때 사용
정렬
상단
가운데
맨 아래
기준선
사용 중단 - 수직 정렬.

예시

다음 코드를 실행하여 HTML에서 태그를 구현하는 방법을 배울 수 있습니다 −

<!DOCTYPE html>
<html>
   <head>
      <title>HTML thead Tag</title>
   </head>
   <body>
      <table style = "width:100%" border = "1">
         <thead>
            <tr>
               <td colspan = "4">This is the head of the table</td>
            </tr>
         </thead>
         <tfoot>
            <tr>
               <td colspan = "4">This is the foot of the table</td>
            </tr>
         </tfoot>
         <tbody>
            <tr>
               <td>Cell 1</td>
               <td>Cell 2</td>
               <td>Cell 3</td>
               <td>Cell 4</td>
            </tr>
            <tr>
            ...more rows here containing four cells...
            </tr>
         </tbody>
     
         <tbody>
            <tr>
               <td>Cell 1</td>
               <td>Cell 2</td>
               <td>Cell 3</td>
               <td>Cell 4</td>
            </tr>
            <tr>
            ...more rows here containing four cells...
            </tr>
         </tbody>
      </table>
   </body>
</html>