views:

55

answers:

2

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

Thanks.

+1  A: 

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).

David Thomas
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 Van Wyk
@Geoffrey, yeah. If you break a url with a space or line-break then it won't be recognised.
David Thomas
To that end, you may consider shortening your image or link paths if code readability is that important.
Marcus
@Marcus, the link path I got from another company, It is part of a site seal.
Geoffrey Van Wyk
A: 

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.

bobince