Search code examples
htmlword-wrap

How does one write HTML attributes over more than one line?


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


Solution

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