This is one of the cruxes of server side code generation, the ASP processor only processes ASP code (code inside the in-line code blocks <% %>
).
This means that any other HTML is left "as is" including special characters like carriage return and linefeed.
So when ASP processes your page it sees
⏎
<!DOCTYPE html>
⏎ Denotes Carriage Return, LineFeed
So as you already state in the question the only way to avoid this is placing the in-line code block on the same line.
<% pippa="Camilla" %><!DOCTYPE html>
The other approach is to break your HTML and your code assignment into different sections. I usually do this by placing my HTML inside it's own Sub
/ Function
and pass or assign variables earlier in the page using an Init()
Function, you still find yourself dealing with code like this though;
<%
Sub DisplayHTML()
%><!DOCTYPE html>
...
</html><% End Sub %>
Which isn't pretty, so I tend to ignore trailing new lines unless it's affecting the rendering of the page (IE compatibility mode etc).
Another way of dealing with HTML inside your code is to build HTML templates to load the HTML and replace values defined by place-holders.
See How to edit the html from ASP in a better way?