Challenge - 5 Problems
Textarea Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate2:00remaining
What will the textarea display initially?
Consider this HTML code:
What text will appear inside the textarea when viewed in a browser?
<textarea>Hello World!</textarea>
What text will appear inside the textarea when viewed in a browser?
HTML
<textarea>Hello World!</textarea>
Attempts:
2 left
💡 Hint
Remember that inside HTML, new lines inside textarea are rendered as line breaks.
✗ Incorrect
The textarea preserves line breaks inside its content. The \n inside the HTML source is interpreted as a new line, so the text appears on two lines: 'Hello' on the first line and 'World!' on the second.
📝 Syntax
intermediate1:30remaining
Which textarea attribute controls the visible width?
You want to set the visible width of a textarea to 40 characters. Which attribute should you use?
Attempts:
2 left
💡 Hint
Think about the standard HTML attribute for textarea width in characters.
✗ Incorrect
The 'cols' attribute sets the visible width of a textarea in characters. Other options like 'width' or 'size' are not valid for textarea.
❓ accessibility
advanced2:00remaining
Which option correctly associates a label with a textarea for accessibility?
You want to make sure screen readers correctly identify the textarea. Which HTML snippet correctly links the label to the textarea?
Attempts:
2 left
💡 Hint
The 'for' attribute on label should match the textarea's id.
✗ Incorrect
Option D uses the 'for' attribute on the label matching the textarea's 'id', which is the standard way to associate labels with form controls for accessibility. Option D nests textarea inside label which is valid but less explicit. Option D uses aria-label which is valid but less preferred than visible label. Option D uses 'name' on label which is invalid.
❓ layout
advanced2:00remaining
How to make a textarea fill its container width responsively?
You want a textarea to always fill 100% of its container's width and adjust on window resize. Which CSS rule achieves this?
HTML
<textarea></textarea>
Attempts:
2 left
💡 Hint
Consider how padding and borders affect width and how to include them.
✗ Incorrect
Setting width to 100% makes the textarea fill its container width. Adding 'box-sizing: border-box' ensures padding and borders are included inside that width, preventing overflow. Option A uses viewport width which ignores container size. Option A only limits max width but doesn't set width. Option A uses auto width which depends on content.
🧠 Conceptual
expert2:30remaining
What happens if you set both rows and style height on a textarea?
Given this HTML:
Which statement is true about the textarea's height?
<textarea rows="4" style="height: 200px;"></textarea>
Which statement is true about the textarea's height?
HTML
<textarea rows="4" style="height: 200px;"></textarea>
Attempts:
2 left
💡 Hint
CSS styles override HTML attributes when both affect the same property.
✗ Incorrect
The 'rows' attribute sets the height in terms of text lines, but an explicit CSS height style overrides this. So the textarea will be 200px tall regardless of rows. Browsers do not throw errors for this.