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 / input type="range"

HTML / Reference / input type="range"

type이 range인 input은 지정한 범위 내의 숫자를 선택할 수 있게 하는 양식입니다. 슬라이드로 값을 선택합니다.

HTML / Reference / label

HTML / Reference / label

label은 폼의 양식에 이름 붙이는 태그입니다. 주요 속성은 for입니다. label의 for의 값과 양식의 id의 값이 같으면 연결됩니다. label을 클릭하면, 연결된 양식에 입력할 수 있도록 하거나, 체크를 하거나, 체크를 해제합니다.

HTML / Reference / em, strong

HTML / Reference / em, strong

em 태그는 주로 말투나 감정적인 강조 또는 문장의 맥락에서 중요한 부분을 나타낼 때 사용합니다. strong 태그는 중요성, 경고 또는 텍스트에서 매우 중요한 정보를 나타낼 때 사용됩니다.

HTML / Reference / video

HTML / Reference / video

video는 HTML 문서에 동영상을 삽입하는 태그입니다. HTML5에서 추가된 것이므로, HTML5를 지원하지 않는 웹브라우저(예를 들어 IE 8 이하)에서는 작동하지 않습니다.

HTML / Reference / textarea

HTML / Reference / textarea

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

HTML / Reference / input type="date"

HTML / Reference / input type="date"

type이 date인 input은 날짜를 입력 받기 위한 양식입니다. 웹브라우저마다, 같은 웹브라우저라도 버전에 따라 표현 방식이 다릅니다.

HTML / Reference / img

HTML / Reference / img

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

HTML / Reference / figure, figcaption

HTML / Reference / figure, figcaption

figure는 사진, 이미지, 다이어그램 등을 감싸는 테그입니다. figcaption은 figure 요소에 캡션을 만듭니다. figure 요소의 자식 요소이며, 제일 처음 또는 제일 마지막에 위치합니다.

HTML / Reference / form

HTML / Reference / form

form은 HTML에서 사용자 입력을 서버로 전송하는 양식을 정의할 때 사용됩니다. 입력 받은 값을 어디로 전송할지, 어떤 방식으로 전송할지 정합니다. form 태그 안에 input, select, textarea 등 양식이 들어갑니다.

HTML / Reference / input type="time"

HTML / Reference / input type="time"

type이 time인 input은 시간을 입력 받기 위한 양식입니다. 웹브라우저마다, 같은 웹브라우저라도 버전에 따라 표현 방식이 다릅니다.