FAQ: Learn HTML: Forms - Textarea element

This community-built FAQ covers the “Textarea element” exercise from the lesson “Learn HTML: Forms”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Introduction to HTML

FAQs on the exercise Textarea element

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hello. Why can’t textarea element left blank? Meaning the default text between textarea tags

1 Like

When writing the code for a Textarea Element, why do you need to add the for, id, and name?

<form> <label for="blog">New Blog Post: </label> <br> <textarea id="blog" name="blog" rows="5" cols="30"></textarea>

you can, why shouldn’t this be possible? Default text is really useful

the for and id are used to associate the label and the element, the id can also be used for styling

the name is used form submission.

1 Like

whats the big difference between id attribute and name atrribute

id is for styling and associating input element with label

name attribute is used when sending information to the back-end of your website.

1 Like

are we learning back end in next section

no, that would be throwing you into the deep. Of course you ca google about form submission to get a general idea. be careful not to drown.


i think that the textarea element in exercise: “LEARN HTML: FORMS - Textarea element” would be better suited to use placeholder text rather than text that the user has to delete before they can type. It makes the form have better usability and user experience.

it would look like this:

<textarea id="extra" name="extra" rows="3" cols="40" placeholder="Special Instructons..."></textarea>
1 Like

In a backward compatible world, especially screen readers, placeholder attribute may not be supported, hence the legacy use of value text. The aim is the same, though… To indicate the type of content expected in the field. The specifications as they are currently defined still stipulate this.


A hint to the user of what can be entered in the control. Carriage returns or line-feeds within the placeholder text must be treated as line breaks when rendering the hint.

Note: Placeholders should only be used to show an example of the type of data that should be entered into a form; they are not a substitute for a proper <label> element tied to the input. See Labels and placeholders in : The Input (Form Input) element for a full explanation.


1 Like

Is it possible to make the default text disappear when clicked on the textarea field on the page by the user.

For that, the placeholder attribute exist:

<textarea placeholder="some value"></textarea>

Why are input type=“text” and textarea elements separate at all? As they are both text input boxes, wouldn’t the textarea element just be a styled input type=“text”? Or is there another difference I’m not aware of yet?

In HTML5, the default type is text so we don’t need to declare a type if it is going to be text. Were we required to set this, then it would have to be applied to both input and textarea.elements.

Not sure I caught the complete gist of your question, so spur me along if this is not the answer you were looking for.

Thanks for your reply. I’m more wondering why the INPUT with type=text and TEXTAREA elements are separated at all, if TEXTAREA is only a larger version of INPUT type=text? Wouldn’t that be a styling difference, to be done in CSS, rather than a functional difference in HTML? Is there a functional difference between these 2 elements that I’m not realizing?

1 Like

TEXTAREA allows line breaks, INPUT does not (I believe; correct me if I’m wrong).

As for the type, I’m not even sure we can declare a different type than ‘text’, or even need to in the older iterations of HTML. It’s defined as a text area.

Ideally, we squeeze as much functionality out of our HTML as possible, before introducing styles; and, we squeeze as much behavior out of our CSS as possible before introducing JavaScript.

When inputs are expected to be bits of data, then <input> and when expecting prose, <textarea>. HTML5 added a significant number of types to the input element. Be sure to look up these elements at w3.org or MDN.

Got it. Line breaks are the difference in functionality I wasn’t realizing, but do now. Thanks!

Other than ‘text’ as type options in an input tag, there are: ‘number’, ‘range’, ‘checkbox’, ‘radio’, etc… Then you have input lists and datalists, too.

1 Like

What is an example of when I may want to set a default text in the element? I see that it does not go away when someone starts typing. Thank you.

When an input field is more commonly than not given a specific string, we can assume it is the consensus, at which point by learning from our users we can make that input a default.

If our audience is from the Greater Toronto Area we might supply Maple Leafs to the question, “Which team do you want to win the Stanley Cup?” The user need only click Okay or press Enter.

If we cannot justify a default value, then we should use a placeholder to suggest or advise, and not give a value.

<label>Which team do you want to win the Stanley Cup? 
<input value="Maple Leafs" name="stanley-cup-hopeful">

<label for="name">Name: </label>
<input id="name" name="name" placeholder="Type your name">

What does cols relate to? I am familiar with grid systems, but what is the number of columns relating to without a defined grid system?