Peregring-lk Peregring-lk - 11 months ago 53
HTML Question

String attribute values in multiple lines, HTML

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.


You can use @laaposto suggestion as long as there's no space between lines.

If you don't want to follow that rule, then you need to use javascript to remove the spaces:

var anchor = document.getElementsByTagName("a");

for(var i=0; i<= anchor.length; i++) {
    var href = anchor[i].href.replace(/%20/g,'');
    anchor[i].href = href;     

Fiddle Demo

or easier with jQuery:

var href = $('a').attr('href').replace(/ /g,'');
$('a').attr('href', href);

Fiddle Demo