5

Can I use enter or line break to separate HTML attributes within an HTML tag?

For example:

<input
    type="text"
    name="usrnm"
    placeholder="Username"
/>
2
  • Next time, you could just do it and see what happens. If it works, you could test it in a html validator to check if it's valid.
    – Martijn
    Commented Mar 4, 2015 at 11:41
  • I don't have no laptop with me when I wrote this, and I was in hurry. I'll try to be careful next time.
    – user50213
    Commented Mar 12, 2015 at 6:43

2 Answers 2

3

Although it is not completely conventional (in terms of industry standards for the markup language), it will function. Just put your example into a .html file:

<html>
<head>
    <title>
        Page
    </title>
</head>
<body>
    <input
        type = "text"
        name="usrnm"
        placeholder="Username"
    />
</body>
</html>

You'll notice that this does render correctly.

0

Yes. It is perfectly functional. Extra spaces, tabs and newlines don't really affect HTML, but it will almost always annoy the hell out of your coworkers. Don't do that.

1
  • I'll use newlines when I work alone. Thanks for the tips.
    – user50213
    Commented Mar 12, 2015 at 6:44

Your Answer

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