code / samp / kbd / var / pre 태그 차이

캐논볼 2015. 7. 22. 14:37

 

<code>태그는 컴퓨터나 프로그래밍 코드 일부를 그대로 표시하고자 할 때 유용합니다

 

<samp>태그는 컴퓨터 프로그램에서 샘플을 출력할 때

 

<kbd>태그는 키보드 입력을 지정할 때

 

<var>태그는 변수를 입력할 때 유용합니다.

 

 

<pre> 역시, 미리 작성된 텍스트를 있는 그대로 표시해주며, 블록 형태로 사용될 수 있습니다.

 

즉, 여러 줄의 코드를 그대로 출력하고자 할 때  위의 code, samp, kbd, var등을 둘러싼 형태로 사용 합니다.

 

 

code 사용 예:

 

 

<pre><code>function Panel(element, canClose, closeHandler) {
  this.element = element;
  this.canClose = canClose;
  this.closeHandler = function () { if (closeHandler) closeHandler() };
}</code></pre>

 

 

▶실행화면

 

function Panel(element, canClose, closeHandler) {
  this.element = element;
  this.canClose = canClose;
  this.closeHandler = function () { if (closeHandler) closeHandler() };
}

 

 

 

 

samp 사용 예:

 

<p>컴퓨터를 하던 중 <samp>Oops…the system encountered a problem (#707)</samp>라는 에러 메시지가 떴다</p>

 

 

▶실행화면

 

컴퓨터를 하던 중 Oops…the system encountered a problem (#707)라는 에러 메시지가 떴다

 

kbd 사용 예: 

 

<p>취소하려면 <kbd><kbd>Ctrl</kbd>+<kbd>z</kbd></kbd>를 입력하시오</p>

 

 

▶실행화면

취소하려면 Ctrl+z를 입력하시오

 

 

var 사용 예:  

 

<p><var>n</var>의 수만큼 곱하시오</p>

 

▶실행화면

 

n의 수만큼 곱하시오

 

 

pre 사용 예:

 

<pre>                maxling

it is with a          heart
               heavy

that i admit loss of a feline
        so           loved

a friend lost to the
        unknown
                                (night)

~cdr 11dec07</pre>  

 

▶실행화면

 

                maxling

it is with a          heart
               heavy

that i admit loss of a feline
        so           loved

a friend lost to the
        unknown
                                (night)

~cdr 11dec07