2

I have an HTML element that looks something like,

<element src="http://lsdjflksjdfkjewiojeriowjekwjekfljsdkfjisdjrsekjfijsiejisjojfsjlfejeileldjfsleisldkjfsiejljefijeljslefifjfsleif">
</element>

See how long that is?

I want to break up the src link into multiple lines.

In Python you would just use \ to break a long string into multiple lines. In JavaScript, you just use + "rest of string" to break it into multiple lines. What is the case for HTML? The browser wants to interpret my attempt as white space...

So when I did:

<element  
  src="http://lsdjflksjdfkjewiojeriowjekwjekfljsdkf
  jisdjrsekjfijsiejisjojfsjlfejeileldjfsleisldkjfsiejljefi
  jeljslefifjfsleif">
</element>

It inserted a bunch of %20 where the line breaks were. What else should I try?

On a similar post on Stack Overflow that addresses this issue, it suggests using JavaScript to split the lines up, which seems like overkill, and the answer that suggested splitting after '/'s in the URL seems not to work unless you cram the entire element on the left side of the page which would cause horrible formatting issues... Otherwise, it still put spaces in the link.

M--
  • 25,431
  • 8
  • 61
  • 93
  • 1
    Why do you want to break it? Almost all editors break lines after a certain amount of characters, so it's still readable. – Reeno Jan 11 '16 at 18:53
  • Well, perhaps my editor is a piece of ...... work. The html coding standard is to not go over 80 characters. This thing goes past 80 chars. Hence why I care. I'm using eclipse. I have the margin line set so I can see it when it goes past 80. "When using an HTML editor, it is inconvenient to scroll right and left to read the HTML code.Try to avoid code lines longer than 80 characters." –  Jan 11 '16 at 18:57
  • @TylerH that only works for `href` attributes, not `src`... – Heretic Monkey Sep 17 '21 at 16:31
  • @HereticMonkey It's for both as the accepted answer of the target indicates. I added that second link to the close banner here for additional clarity, but it's also probably irrelevant today because those features are deprecated. – TylerH Sep 17 '21 at 17:30

1 Answers1

0

Google URL Shortener has been retired and has transitioned to Firebase Dynamic Links.

But in general, using a link shortener for external resources is a pretty terrible idea. There will inevitably be some overhead in using an external link shortener, you'll be at their mercy in the event of an outage or EOL, and there may be the possibility of redirect/poison attacks as well.

M--
  • 25,431
  • 8
  • 61
  • 93
zaump
  • 147
  • 2
  • 12