Is it possible to have attribute values that span multiple lines?
<div class="big
left
important"> some content </div>
Does anyone know if this breaks things / has good browser support?
Returns, tabs, etc are considered white space and should be treated the same. I've seen and done formatting similar to how you have posted it. Some may discourage it. But I've never seen anything choke on it.
When creating my own web robots, I've had to clean up the white space in order for them to function because ultimately the robot runs into examples such as yours.
The class
attribute is by HTML 4.01 specs of type:
class
= cdata-list [CS]This attribute assigns a class name or set of class names to an element. Any number of elements may be assigned the same class name or names. Multiple class names must be separated by white space characters.
That cdata-list references then to:
CDATA is a sequence of characters from the document character set and may include character entities. User agents should interpret attribute values as follows:
- Replace character entities with characters,
- Ignore line feeds,
- Replace each carriage return or tab with a single space.
Taken all this into account then what you suggest in your question is perfectly OK with the specs. I know that browser-support is good for that.
More generally, whitespace incl. line feeds and carriage return are allowed in quoted attribute values since the first version of HTML. Browser support is very good for that.
精彩评论