Home  >  Article  >  Web Front-end  >  How to Indent Multiple-Line Label Text on Forms with Limited Width?

How to Indent Multiple-Line Label Text on Forms with Limited Width?

DDD
DDDOriginal
2024-10-24 07:21:02376browse

How to Indent Multiple-Line Label Text on Forms with Limited Width?

Indent Label Text on Multiple Lines for Limited-Width Forms

In a form with limited width, while longer label text may wrap onto multiple lines, only the first line is often indented due to the associated input element. This can result in an unorganized appearance.

To address this issue and indent all lines consistently, you can employ CSS:



.checkbox-field {</p>
<pre class="brush:php;toolbar:false">display: flex;
flex-direction: row;

}

<div class="checkbox-field"></p>
<pre class="brush:php;toolbar:false"><input type="checkbox" id="check">
<label for="check">Field 2 Label, may be longer than normal, This is an example for this lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem</label>



The CSS code:

  • Applies a flex box to the container element .checkbox-field.
  • Sets the flex direction to row, aligning elements horizontally.

The HTML code:

  • Creates a container element to hold the input and label elements.
  • Uses display: flex on the container to enable flexbox layout.
  • Aligns the input and label horizontally using flex-direction: row.

With these adjustments, the label text will wrap and indent consistently, resulting in a visually organized form.

The above is the detailed content of How to Indent Multiple-Line Label Text on Forms with Limited Width?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Can JavaScript Access Values of Invalid CSS Properties?Next article:Can JavaScript Access Values of Invalid CSS Properties?

Related articles

See more