The <wbr>
HTML element is an invisible line break that does not affect the layout of the content but allows browsers to insert a line break if needed due to space constraints. It’s useful for creating multiline input fields or preserving certain elements of a web page in case it has to be displayed on smaller screens.
Here’s an example of how you can use <wbr>
:
<p>Please enter your name: <input type="text" id="name" value="" size="10"><wbr></p>
In this example, the input field has a width of 10 characters. If the user enters more than 10 characters, the browser will automatically insert line breaks to prevent any overflow.
The <wbr>
tag has one attribute:
clear
– This sets whether the break should clear all floating elements before it or not. The possible values for this attribute are “left”, “right” and “none”.
Here’s an example of how you can use the clear
attribute:
<p>Please enter your name: <input type="text" id="name" value="" size="10"><wbr clear="left"></p>
In this example, if a line break is inserted before the input field due to space constraints, it will clear all floating elements on its left side.