본문 바로가기

[R]HTML 양식 요소(HTML Form Elements)

This chapter describes all HTML form elements.

이 장에서는 모든 HTML 양식 요소를 설명합니다.




The <input> Element

<input> 요소


The most important form element is the <input> element.

가장 중요한 양식 요소는 <input>요소입니다.

The <input> element can be displayed in several ways, depending on the type attribute.

<input>요소는에 따라 여러 가지 방법으로 표시 할 수 있습니다 type 속성.


Example

1
<input name="firstname" type="text">
cs


If the type attribute is omitted, the input field gets the default type: "text".

는 IF type"텍스트"속성이 생략 입력 필드는 기본 유형을 가져옵니다.


All the different input types are covered in the next chapter.
모든 다른 입력 유형은 다음 장에서 다룹니다.




The <select> Element

<select> 요소


The <select> element defines a drop-down list:

<select>요소는 정의 드롭 다운 목록 :


Example

1
2
3
4
5
6
<select name="cars">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="fiat">Fiat</option>
  <option value="audi">Audi</option>
</select>

cs



The <option> elements defines an option that can be selected.

<option>요소는 선택할 수있는 옵션을 정의합니다.

By default, the first item in the drop-down list is selected.

기본적으로 드롭 다운 목록의 첫 번째 항목이 선택됩니다.

To define a pre-selected option, add the selected attribute to the option:

미리 선택된 옵션을 정의하려면 해당 옵션을 옵션에 추가하십시오 selected.


Example

1
<option value="fiat" selected>Fiat</option>
cs



Visible Values:

표시 값 :


Use the size attribute to specify the number of visible values:

사용 size표시 값의 수를 지정하는 속성 :


Example

1
2
3
4
5
6
<select name="cars" size="3">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="fiat">Fiat</option>
  <option value="audi">Audi</option>
</select>
cs



Allow Multiple Selections:

다중 선택 허용 :


Use the multiple attribute to allow the user to select more than one value:

사용 multiple사용자가 하나 개의 값보다 더 선택할 수 있도록 속성을 :


Example

1
2
3
4
5
6
<select name="cars" size="4" multiple>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="fiat">Fiat</option>
  <option value="audi">Audi</option>
</select>
cs





The <textarea> Element

<textarea> 요소


The <textarea> element defines a multi-line input field (a text area):

<textarea>소자는 여러 줄의 입력 필드 (정의 텍스트 영역 )


Example

1
2
3
<textarea name="message" rows="10" cols="30">
The cat was playing in the garden.
</textarea>
cs



The rows attribute specifies the visible number of lines in a text area.

이 rows속성은 텍스트 영역의 보이는 선의 수를 지정합니다.

The cols attribute specifies the visible width of a text area.

cols속성은 텍스트 영역의 가시 폭을 지정한다.

This is how the HTML code above will be displayed in a browser:

위의 HTML 코드가 브라우저에 표시되는 방법입니다.



You can also define the size of the text area by using CSS:

CSS를 사용하여 텍스트 영역의 크기를 정의 할 수도 있습니다.


Example

1
2
3
<textarea name="message" style="width:200px; height:600px">
The cat was playing in the garden.
</textarea>
cs

 




The <button> Element

<button> 요소


The <button> element defines a clickable button:

<button>요소는 클릭 할 수있는 정의 단추를 :


Example

1
<button type="button" onclick="alert('Hello World!')">Click Me!</button>
cs



This is how the HTML code above will be displayed in a browser:

위의 HTML 코드가 브라우저에 표시되는 방법입니다.



Note: Always specify the type attribute for the button element. Different browsers may use different default types for the button element.

주 : 항상 button 요소 의 type 속성을 지정하십시오 . 다른 브라우저는 버튼 요소에 대해 다른 기본 유형을 사용할 수 있습니다.




HTML5 Form Elements

HTML5 양식 요소


HTML5 added the following form elements:

HTML5는 다음 양식 요소를 추가했습니다.

  • <datalist>
  • <output>

Note: Browsers do not display unknown elements. New elements that are not supported in older browsers will not "destroy" your web page.

참고 : 브라우저는 알 수없는 요소를 표시하지 않습니다. 구형 브라우저에서 지원되지 않는 새로운 요소는 웹 페이지를 "파괴"하지 않습니다.





HTML5 <datalist> Element

HTML5 <datalist> 요소


The <datalist> element specifies a list of pre-defined options for an <input> element.

<datalist>요소는에서 미리 정의 된 옵션의리스트를 지정 <input>소자.

Users will see a drop-down list of the pre-defined options as they input data.

사용자는 데이터를 입력 할 때 사전 정의 된 옵션의 드롭 다운 목록을 볼 수 있습니다.

The list attribute of the <input> element, must refer to the id attribute of the <datalist> element.

list의 속성 <input>요소는 참조해야 id의 속성 <datalist>요소입니다.


Example

1
2
3
4
5
6
7
8
9
10
<form action="/action_page.php">
  <input list="browsers">
  <datalist id="browsers">
    <option value="Internet Explorer">
    <option value="Firefox">
    <option value="Chrome">
    <option value="Opera">
    <option value="Safari">
  </datalist
</form>
cs





HTML5 <output> Element

HTML5 <output> 요소


The <output> element represents the result of a calculation (like one performed by a script).

<output>소자는 계산 결과를 나타낸다 (스크립트를 수행 등).



Example

Perform a calculation and show the result in an <output> element:

계산을 수행하고 결과를 <output>요소 에 표시합니다 .


1
2
3
4
5
6
7
8
9
10
11
<form action="/action_page.php"
  oninput="x.value=parseInt(a.value)+parseInt(b.value)">
  0
  <input type="range"  id="a" name="a" value="50">
  100 +
  <input type="number" id="b" name="b" value="50">
  =
  <output name="x" for="a b"></output>
  <br><br>
  <input type="submit">
</form>
cs





Test Yourself with Exercises!

      



HTML Form Elements

HTML 양식 요소


= new in HTML5.

= HTML5의 새로운 기능.


Tag Description
<form> Defines an HTML form for user input
사용자 입력을위한 HTML 양식을 정의합니다.
<input> Defines an input control
입력 컨트롤을 정의합니다.
<textarea> Defines a multiline input control (text area)
여러 줄 입력 컨트롤 (텍스트 영역)을 정의합니다.
<label> Defines a label for an <input> element
<input> 요소에 대한 레이블을 정의합니다.
<fieldset> Groups related elements in a form
양식의 관련 요소 그룹화
<legend> Defines a caption for a <fieldset> element
<fieldset> 요소에 대한 캡션을 정의합니다.
<select> Defines a drop-down list
드롭 다운 목록을 정의합니다.
<optgroup> Defines a group of related options in a drop-down list
드롭 다운 목록에서 관련 옵션 그룹을 정의합니다.
<option> Defines an option in a drop-down list
드롭 다운 목록에서 옵션을 정의합니다.
<button> Defines a clickable button
클릭 가능한 버튼을 정의합니다.
<datalist> Specifies a list of pre-defined options for input controls
입력 컨트롤에 대해 미리 정의 된 옵션 목록을 지정합니다.
<output> Defines the result of a calculation
계산 결과를 정의합니다.






'HTML' 카테고리의 다른 글

[R]HTML 입력 속성(HTML Input Attributes)  (0) 2018.07.05
[R]HTML 입력 유형(HTML Input Types)  (0) 2018.07.04
[R]HTML 양식HTML Forms  (0) 2018.07.02
[R]HTML 과 XHTML(HTML and XHTML)  (0) 2018.07.01
[R]HTML Uniform Resource Locators  (1) 2018.06.30