How to Put an Element on Its Own Line with display: block in CSS
Some elements, such as label and span, sit in the line of text with their neighbors. display: block puts an element on a line of its own, so a label lands above its field instead of beside it.
Syntax
<selector> {
display: block;
}
| Part | What it does |
|---|---|
<selector> | The element to move onto its own line. |
block | Makes the element a block: it starts on a new line, and what follows it starts on the next one. |
MDN's display page says a block generates line breaks both before and after the element, while an inline element doesn't.
The Example
The example is a feedback form with a Comments label and a text area. First you see the label beside the text area, then one rule puts it above.
Step 1: Write the Code
Create a file named index.html in a text editor, such as Visual Studio Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>display: block</title>
</head>
<body>
<form>
<label for="comments">Comments</label>
<textarea id="comments" rows="3"></textarea>
</form>
</body>
</html>
Step 2: Open It in a Browser
Double-click index.html. It opens in your browser:

The label sits to the left of the text area, at the level of its bottom edge: a label is inline, so it shares the line with the text area. The screenshot comes from Chromium 159, the open-source browser that Chrome is built on.
Step 3: Make the Label a Block
Add a style element with a rule for label to head, so the file looks like this:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>display: block</title>
<style>
label {
display: block;
}
</style>
</head>
<body>
<form>
<label for="comments">Comments</label>
<textarea id="comments" rows="3"></textarea>
</form>
</body>
</html>
Step 4: Reload the Page
Save the file and reload the page in your browser:

What Happened
- The label moved onto its own line, and the text area starts right under it.
- The label is now as wide as the page. In a window 800 pixels wide, it measured 784 pixels: a block takes the whole width of its container.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
A typo in the value: display: blocks | The value is invalid and ignored: the label stayed inline, beside the text area | Write block |
| Expecting a block to stay as wide as its text | A block takes the full width: a span with display: block and a yellow background was 784 pixels wide, where it had been 37 | Set a width if it should be narrower |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The element stays on the same line | The rule doesn't match it, or the value is misspelled | Check the selector and block |
| A background suddenly fills the whole line | Blocks are as wide as their container | That's expected, or set a width |
FAQ
What's the difference between inline and block?
An inline element, like label or span, sits in the line with the text around it and is only as wide as its content. A block, like p or div, starts on a new line and takes the full width.
Do I need br to break the line instead?
No. display: block moves the element onto its own line without changing the HTML.
Conclusion
Set display: block on an inline element to give it a line of its own. It also takes the full width of its container, so set a width when it should be narrower.
Additional Resources
- display, on MDN.
