HTML / Reference / textarea

개요

textarea는 여러 줄의 긴 문장을 입력할 수 있는 양식입니다.

문법

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<textarea></textarea>
<textarea></textarea>
<textarea></textarea>

예제 - 기본

col 속성으로 가로 크기를, row 속성으로 세로 크기를 정할 수 있습니다. 하지만, 크기 등 모양은 CSS의 width, height로 정하는 게 좋습니다.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>HTML</title>
<style>
* {
font-size: 16px;
font-family: Consolas, sans-serif;
}
</style>
</head>
<body>
<form>
<p><textarea cols="50" rows="10"></textarea></p>
<p><input type="submit" value="Submit"></p>
</form>
</body>
</html>
<!doctype html> <html lang="ko"> <head> <meta charset="utf-8"> <title>HTML</title> <style> * { font-size: 16px; font-family: Consolas, sans-serif; } </style> </head> <body> <form> <p><textarea cols="50" rows="10"></textarea></p> <p><input type="submit" value="Submit"></p> </form> </body> </html>
<!doctype html>
<html lang="ko">
  <head>
  <meta charset="utf-8">
    <title>HTML</title>
    <style>
      * {
        font-size: 16px;
        font-family: Consolas, sans-serif;
      }
    </style>
  </head>
  <body>
    <form>
      <p><textarea cols="50" rows="10"></textarea></p>
      <p><input type="submit" value="Submit"></p>
    </form>
  </body>
</html>

예제 - 기본값

기본값이 필요하다면 <textarea>와 </textarea> 사이에 입력합니다. 여러 줄이 가능합니다.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>HTML</title>
<style>
* {
font-size: 16px;
font-family: Consolas, sans-serif;
}
textarea {
width: 80%;
height: 100px;
}
</style>
</head>
<body>
<form>
<p><textarea>
123
123
</textarea></p>
<p><input type="submit" value="Submit"></p>
</form>
</body>
</html>
<!doctype html> <html lang="ko"> <head> <meta charset="utf-8"> <title>HTML</title> <style> * { font-size: 16px; font-family: Consolas, sans-serif; } textarea { width: 80%; height: 100px; } </style> </head> <body> <form> <p><textarea> 123 123 </textarea></p> <p><input type="submit" value="Submit"></p> </form> </body> </html>
<!doctype html>
<html lang="ko">
  <head>
  <meta charset="utf-8">
    <title>HTML</title>
    <style>
      * {
        font-size: 16px;
        font-family: Consolas, sans-serif;
      }
      textarea {
        width: 80%;
        height: 100px;
      }
    </style>
  </head>
  <body>
    <form>
      <p><textarea>
123
123
      </textarea></p>
      <p><input type="submit" value="Submit"></p>
    </form>
  </body>
</html>

예제 - 안내 문구

placeholder 속성으로 안내 문구를 넣을 수 있습니다.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>HTML</title>
<style>
* {
font-size: 16px;
font-family: Consolas, sans-serif;
}
textarea {
width: 80%;
height: 100px;
}
</style>
</head>
<body>
<form>
<p><textarea placeholder="Input some text."></textarea></p>
<p><input type="submit" value="Submit"></p>
</form>
</body>
</html>
<!doctype html> <html lang="ko"> <head> <meta charset="utf-8"> <title>HTML</title> <style> * { font-size: 16px; font-family: Consolas, sans-serif; } textarea { width: 80%; height: 100px; } </style> </head> <body> <form> <p><textarea placeholder="Input some text."></textarea></p> <p><input type="submit" value="Submit"></p> </form> </body> </html>
<!doctype html>
<html lang="ko">
  <head>
  <meta charset="utf-8">
    <title>HTML</title>
    <style>
      * {
        font-size: 16px;
        font-family: Consolas, sans-serif;
      }
      textarea {
        width: 80%;
        height: 100px;
      }
    </style>
  </head>
  <body>
    <form>
      <p><textarea placeholder="Input some text."></textarea></p>
      <p><input type="submit" value="Submit"></p>
    </form>
  </body>
</html>

예제 - 읽기 전용

readonly를 추가하면 읽기만 가능합니다.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>HTML</title>
<style>
* {
font-size: 16px;
font-family: Consolas, sans-serif;
}
textarea {
width: 80%;
height: 100px;
}
</style>
</head>
<body>
<form>
<p><textarea placeholder="Read Only" readonly></textarea></p>
<p><input type="submit" value="Submit"></p>
</form>
</body>
</html>
<!doctype html> <html lang="ko"> <head> <meta charset="utf-8"> <title>HTML</title> <style> * { font-size: 16px; font-family: Consolas, sans-serif; } textarea { width: 80%; height: 100px; } </style> </head> <body> <form> <p><textarea placeholder="Read Only" readonly></textarea></p> <p><input type="submit" value="Submit"></p> </form> </body> </html>
<!doctype html>
<html lang="ko">
  <head>
  <meta charset="utf-8">
    <title>HTML</title>
    <style>
      * {
        font-size: 16px;
        font-family: Consolas, sans-serif;
      }
      textarea {
        width: 80%;
        height: 100px;
      }
    </style>
  </head>
  <body>
    <form>
      <p><textarea placeholder="Read Only" readonly></textarea></p>
      <p><input type="submit" value="Submit"></p>
    </form>
  </body>
</html>

예제 - 비활성화

disabled를 추가하면 입력을 할 수 없고, 배경색이 바뀝니다.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>HTML</title>
<style>
* {
font-size: 16px;
font-family: Consolas, sans-serif;
}
textarea {
width: 80%;
height: 100px;
}
</style>
</head>
<body>
<form>
<p><textarea placeholder="Disabled" disabled></textarea></p>
<p><input type="submit" value="Submit"></p>
</form>
</body>
</html>
<!doctype html> <html lang="ko"> <head> <meta charset="utf-8"> <title>HTML</title> <style> * { font-size: 16px; font-family: Consolas, sans-serif; } textarea { width: 80%; height: 100px; } </style> </head> <body> <form> <p><textarea placeholder="Disabled" disabled></textarea></p> <p><input type="submit" value="Submit"></p> </form> </body> </html>
<!doctype html>
<html lang="ko">
  <head>
  <meta charset="utf-8">
    <title>HTML</title>
    <style>
      * {
        font-size: 16px;
        font-family: Consolas, sans-serif;
      }
      textarea {
        width: 80%;
        height: 100px;
      }
    </style>
  </head>
  <body>
    <form>
      <p><textarea placeholder="Disabled" disabled></textarea></p>
      <p><input type="submit" value="Submit"></p>
    </form>
  </body>
</html>

같은 카테고리의 다른 글
HTML / Reference / pre

HTML / Reference / pre

pre 태그는 HTML에서 "preformatted text"를 정의하는 데 사용됩니다. 이 태그는 HTML 문서에서 텍스트를 작성한 그대로 표시하도록 하여, 공백과 줄바꿈을 유지하는 특징이 있습니다. 일반적으로 코드 블록, ASCII 아트, 또는 공백과 줄바꿈을 유지해야 하는 텍스트를 표시할 때 사용됩니다.

HTML / Reference / textarea

HTML / Reference / textarea

textarea는 여러 줄의 긴 문장을 입력할 수 있는 양식입니다. col 속성으로 가로 크기를, row 속성으로 세로 크기를 정할 수 있습니다. 하지만, 크기 등 모양은 CSS의 width, height로 정하는 게 좋습니다.

HTML / Reference / abbr

HTML / Reference / abbr

abbr은 약자(abbreviation)임을 나타냅니다. title 속성에 약자의 뜻을 넣으면, 마우스를 약자 위에 올렸을 때 그 뜻이 툴팁으로 나옵니다.

HTML / Reference / q

HTML / Reference / q

q는 인용임을 나타내는 태그입니다. 인용임을 나타내는 태그에는 blockquote와 q가 있는데, blockquote는 블록 요소이고 q는 인라인 요소입니다.

HTML / Reference / img

HTML / Reference / img

img는 HTML에서 이미지를 삽입할 때 사용하는 태그입니다. 이 태그는 자체 종료 태그(self-closing)이며, 이미지 파일을 웹 페이지에 표시하는 데 사용됩니다.

HTML / Reference / input type="hidden"

HTML / Reference / input type="hidden"

양식은 보통 사용자가 입력한 값을 활용하기 위해 사용합니다. 하지만, 사용자가 접속한 IP 등 사용자가 입력하지 않아도 필요한 값이 있을 수 있습니다. 이러한 값들은 type이 hidden인 input 태그로 만들어서 넘깁니다.

HTML / Reference / br

HTML / Reference / br

HTML은 연속한 여러 개의 빈 칸 또는 줄바꿈을 하나의 빈 칸으로 인식합니다. 따라서 코드 상에서 줄바꿈을 하거나 여러 번 띄어쓰기를 해도 한 번 띄어쓰기로 표현됩니다. 만약 블록 요소 안에서 줄바꿈을 하고 싶다면 br 태그를 이용합니다.

HTML / Reference / progress

HTML / Reference / progress

progress는 HTML5에서 제공하는 태그로, 작업의 진행 상태를 나타내기 위해 사용됩니다.  주로 파일 업로드, 다운로드, 로딩 진행 상황 등을 시각적으로 보여줄 때 유용합니다. progress 태그는 기본적으로 게이지 형태로 표시되며, 사용자가 커스텀 스타일을 적용할 수도 있습니다.

HTML / Reference / address

HTML / Reference / address

address는 소유자 또는 작성자의 연락처를 나타내는 태그입니다. body 태그 안에 있으면 문서의 소유자 또는 작성자의 연락처를 나타냅니다. article 태그 안에 있으면 기사의 소유자 또는 작성자의 연락처를 나타냅니다. 기본 모양은 기울임꼴입니다.

HTML / Reference / input type="number"

HTML / Reference / input type="number"

type이 number인 input은 숫자를 입력받는 양식입니다. 숫자 이외의 값을 입력하면 경고 메시지를 출력합니다. 숫자 범위, 값의 증감 단위 등을 설정할 수 있는 다양한 속성을 제공합니다. 이 입력 필드는 나이, 수량, 가격 등의 숫자 데이터를 입력받을 때 유용합니다.