Reputation:
I am converting text file into html in C# environment. What I did was changing the extension .txt to .html and replace all the Writeline
with <p>
tags. The output file prints out everything but there's a line break in between two lines. Any suggestion?
checkingWriter = File.AppendText(checkingPath);
checkingWriter.WriteLine("<p>Checking SF data<p>");
Checking results for product: d02100
Checking SF data
Upvotes: 0
Views: 186
Reputation: 24280
If you are talking about the HTML view showing empty space between paragraphs, then that is simply what the <p>
tag does by default in all browsers. The rule is: if the <p>
has content, then show that content and show a bit of empty space before the next element renders. That empty space is called vertical margin.
You can change this behaviour by including this very small CSS definition: p { margin: 0 }
.
Demo:
p { margin: 0 }
<p>Checking SF data<p>
<p>Checking other data<p>
<p>Checking more data<p>
<p>Checking final data<p>
And even though most browsers will auto-close <p>
(for historic reasons), it is better to close them yourself by putting </p>
at the end of each paragraph:
p { margin: 0 }
<p>Checking SF data</p>
<p>Checking other data</p>
<p>Checking more data</p>
<p>Checking final data</p>
And as a response to your comment, it is always possible to include CSS definitions by means of a <style>
tag inside the document like this.
<style type="text/css">
p { margin: 0 }
</style>
You can add a WriteLine()
command to output it.
Upvotes: 1