3

For those attributes that can stretch into infinity and beyond off-screen and do not tolerate white space like urls.

5
  • 3
    Not possible. Did you consider getting a wider screen? Commented Oct 5, 2010 at 22:27
  • 4
    enable line wrapping on your text editor? Commented Oct 5, 2010 at 22:30
  • @djrsargent, I cannot find line wrapping in netbeans 6.8. Commented Oct 5, 2010 at 23:02
  • @Frederic, 23 in. I will accept your comment as the answer. Commented Oct 5, 2010 at 23:03
  • you can't 'accept' a comment as an answer, please ask @Frédéric to post his comment as an anwswer to allow you to accept it, or accept an existing answer at some point. Commented Oct 6, 2010 at 0:24

2 Answers 2

5

There is nothing to stop you breaking attribute lists or attribute values over multiple lines.

<div class="thing"
    title="Foo,
        bar,
        bof
    "
>
    zot
</div>

XHTML 1.0 section C.5 recommends avoiding attribute value newlines for legacy browser support reasons, but the browsers that got this wrong are long gone now.

However note that whilst some browsers will treat newlines in an attribute value as actual newlines, others will convert them to plain spaces.

Sign up to request clarification or add additional context in comments.

Comments

2

Without knowing exactly what your question refers to, it's hard to say; but it's worth pointing out that html is more or less insensitive to white-space, so

<img src="path/to/image.png" height="200px" width="400px" class="title" id="mainTitle" onClick="alert('clicked')" style="display: block; float: right; position: relative;" />

is equivalent to

<img
src="path/to/image.png"
height="200px"
width="400px"
class="title"
id="mainTitle"
onClick="alert('clicked')"
style="display: block; float: right; position: relative;" />

I'm not wholly certain that it's possible, or valid, to separate the attribute/value pairs across lines, but certainly each pairing can be separated from the next/previous pair.

Incidentally, even Notepad allows for line-wrapping (under 'edit' or 'view', I'm not sure which since I switched to Linux full-time a few years back).

4 Comments

What if the value of the src-attribute is extremely long and I want to wrap it over many lines for the sake of readability? If I just press enter within the string, I think an invisible linebreak character will be inserted and the browser will not understand the value correctly.
@Geoffrey, yeah. If you break a url with a space or line-break then it won't be recognised.
To that end, you may consider shortening your image or link paths if code readability is that important.
@Marcus, the link path I got from another company, It is part of a site seal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.