웹표준/HTML5 훑어보기

HTML5 pre 엘리먼트(element)

샷타이거 2010. 5. 28. 17:26

HTML5 pre 엘리먼트(element)

pre 에리먼트는 텍스트 서식등 있는그대로 타이포그래피처럼 보여줄때 쓴다.예로 html이나 스크립트 css소스를 보여줄때 사용한다. 계속포스팅할때 소스를 보여주는 것도 pre엘리먼트를 사용할때이다.

있는그대로 보여주므로 띄우기도 그대로 나오계된다.사용되는예를보자면

  • 이메일이나 빈칸공백이있는것들을 그대로 보여줄 떄
  • 프로그래밍언어나 소스일부분을 보여줄떄
  • ASCII 코드를 보여줄때

첫번째예를 보자 이것은 프로그래밍코드를 보여주느예제이다

This is the Panel constructor:

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

두번째 예 시를보여주는경우이다 띄움,공백이 그대로 나타나게된다

                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
                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