Is it possible, in HTML to write something like:
<a href="bla bla bla bla\ bla bla bla bla">....</a>
The idea is splitting a string attribute in different lines to improve readability.
To add a line break to your HTML code, you use the <br> tag. The <br> tag does not have an end tag. You can also add additional lines between paragraphs by using the <br> tags. Each <br> tag you enter creates another blank line.
You can use the . split() method and the . join() method together to split a string into multiple lines.
Yes that's possible: https://stackoverflow.com/a/38874964/3135511 The secret is to use tab's instead of space As well as to use linebreaks
<a href=" bla bla bla bla bla bla bla bla bla ">....</a>
Background:
A space in a string will be escaped to %20 and so stay in, +but white spaces as tab & line break will be discarded/filtered out.
If you want them in a string write %09
for Tab and %0A%0D
for some CR/LF windows line break. -> That are two bytes one Carrier Return char and some Line Feed char.
No, it is not possible. HTML has no “line continuation” character. If you put a line break in an attribute value, browser behavior varies, but modern browsers behave in the manner documented in HTML5: a line break is allowed, and it is taken literally and stored as a line break in the DOM. This means that href
attribute value is broken and does not work.
The best you do to alleviate the problem of long href
values is to put such a value on a line of its own, without quotation marks:
<a href= http://www.example.com/some-long-path/and-so-on >link</a>
In contrast, the following is allowed and causes as two-liner tooltip (in modern browsers). The point is that the general syntax allows line breaks, but they have consequences, and the specific syntax of an attribute may forbid line breaks.
<a href=foo title="Hello world">bar</a>
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