The task we are going to perform in this article is how do we display a text area in HTML. Let's dive into the article for getting a clear idea on how we display text area.
HTML textarea標籤定義了一個多行純文字編輯控制項。由於文字空間可以容納無限數量的字元(通常是Courier),所以文字以固定寬度字體顯示。在表單中,textarea通常用於收集使用者輸入,例如評論或評價。在提交表單後,表單資料中的參考將需要name屬性。
Let’s look into the following examples to know more about how do we display a textarea in HTML.
在下面的範例中,我們使用了多行輸入控制項。
<!DOCTYPE html> <html> <body> <form action="https://www.tutorialspoint.com/index.htm"> <label for="name">NAME:</label><br> <input type="text" id="name" name="name"><br> <p><label for="comment">About Yourself:</label></p> <textarea id="comment" name="comment" rows="5" cols="35"> I'm from Hyderabad,Telengana </textarea><br> <input type="submit" value="Submit"> </form> </body> </html>
在執行上述腳本時,輸出視窗彈出,顯示了用於輸入姓名的輸入欄位和用於自我介紹的文字區域,以及一個提交按鈕。如果您點擊提交按鈕,表單將會提交。
Considering the following example we are running script to change the context in the text area.
<!DOCTYPE html> <html> <body> Address:<br> <textarea id="tutorial"> kavuri incore 9 Hyderabad </textarea> <button type="button" onclick="myFunction()">Click To Change</button> <script> function myFunction() { document.getElementById("tutorial").value = "Madhapur , Telangana"; } </script> </body> </html>當腳本被執行時,它會產生一個輸出,其中包含一個填充有文字的地址欄位的文字區域,以及一個點擊更改按鈕
If the user clicks on the button, the text in the textarea gets changed.
讓我們考慮另一個例子,我們正在使用textarea標籤
<!DOCTYPE html> <html> <head> <title>HTML textarea Tag</title> </head> <body> <form action = "/cgi-bin/hello_get.cgi" method = "get"> Enter subjects <br/> <textarea rows = "5" cols = "50" name = "description"></textarea> <input type = "submit" value = "submit" /> </form> </body> </html>
When the script gets executed, the output window will pop up, providing the input type for textara along with a submit button.
以上是我們如何在HTML中顯示文字區域?的詳細內容。更多資訊請關注PHP中文網其他相關文章!