I have a button with long text like "Click here to start playing". I want to control the width and display the text in multiple lines. Is it possible in html/css?
The correct way to do things is using things made for the things you need. If you want a line break (enter), use <br> ; If you want to define a paragraph, use <p> . Show activity on this post. According to this, the <br> element is used to insert a line break without starting a new paragraph.
To create a multi-line text input, use the HTML <textarea> tag. You can set the size of a text area using the cols and rows attributes. It is used within a form, to allow users to input text over multiple rows.
The easiest way to have a line break is using the <br> tag on your text. It is used for inserting a single line break.
One of the most simple solutions in your case is: Move the button inside the div. Remove width:200px; Add float:left; style to the div.
Yes, you can have it on multiple lines using the white-space css property :)
input[type="submit"] { white-space: normal; width: 100px; }
<input type="submit" value="Some long text that won't fit." />
add this to your element
white-space: normal; width: 100px;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With