Aligning a Single Line vs the Whole Paragraph

    Alignment applies to the block that contains the caret, not to a single visual line. In a signature or address block whose lines are separated by <br> inside one paragraph, clicking Center moves every line at once. To align one line on its own, that line has to be its own block.

    Which one you get is controlled by a single option, Options.EnterKeyResponse. The editor ships with EnterKeyResponses.LineBreak, so out of the box Enter keeps everything inside one paragraph and alignment is paragraph-wide. Set it to EnterKeyResponses.Paragraph and each line becomes a separate block that aligns independently, which is what a signature-block or template designer usually wants.

    Side by side in the SpiceLogic WinForms HTML Editor: three signature lines sharing one paragraph all move together when centred, while the same three lines as separate paragraphs align individually so only the signer's name centres.
    Side by side in the SpiceLogic WinForms HTML Editor: three signature lines sharing one paragraph all move together when centred, while the same three lines as separate paragraphs align individually so only the signer's name centres.

    Why it happens: alignment is block-level in HTML

    In HTML, text-align applies to a block-level container: <p>, <div>, <li>. It does not align an arbitrary "visual line". If three lines of text live inside a single <p> joined by <br>, setting text-align: center on that paragraph centres all three lines, because all three share the same block. To align only one of those lines, that line has to be its own block.

    <!-- One paragraph, three lines: align centres every line -->
    
    <p style="text-align:center">Sarah Lee<br>VP of Customer Success<br>+1 555 0100</p>
    
    
    
    <!-- Three paragraphs: each can be aligned independently -->
    
    <p style="text-align:center">Sarah Lee</p>
    
    <p>VP of Customer Success</p>
    
    <p>+1 555 0100</p>

    Same visible text. Different DOM. Different alignment behaviour. The question becomes: when the designer hits Enter at the end of a line, do you want the editor to produce a new block, or a soft line break?

    The one option that controls it: EnterKeyResponse

    Options.EnterKeyResponse takes one of two values from the EnterKeyResponses enum in SpiceLogic.HtmlEditor.Abstractions:

    EnterKeyResponses.Paragraph - Enter starts a new paragraph; the editor emits </p><p>. Each line becomes a separate block, so the alignment toolbar buttons affect only the paragraph containing the caret. This is what most word-processor users expect, and it is what a signature-block or template designer wants. It is not the shipped default, so set it explicitly.

    EnterKeyResponses.LineBreak - the shipped default. Enter inserts a soft <br> inside the current paragraph. Everything typed stays inside one block, so the alignment toolbar buttons apply to the whole block at once. This is closer to a plain text-editor feel and useful for single-paragraph composer fields like reply boxes or short subject-line entries.

    // Per-line alignment is what a signature-block designer needs:
    
    htmlEditor1.Options.EnterKeyResponse =
    
        SpiceLogic.HtmlEditor.Abstractions.EnterKeyResponses.Paragraph;
    
    
    
    // Force single-block behaviour (Enter = <br>, alignment is paragraph-wide):
    
    htmlEditor1.Options.EnterKeyResponse =
    
        SpiceLogic.HtmlEditor.Abstractions.EnterKeyResponses.LineBreak;
    A host application options strip bound to the SpiceLogic WinForms HTML Editor's EnterKeyResponse property, set to Paragraph so the Enter key starts a new alignable block rather than a soft line break.
    A host application options strip bound to the SpiceLogic WinForms HTML Editor's EnterKeyResponse property, set to Paragraph so the Enter key starts a new alignable block rather than a soft line break.

    Fixing legacy templates: a single line trapped inside a paragraph

    Some legacy templates have signature blocks already saved as one <p> with <br> separators. To align only the middle line, the designer splits that paragraph so the middle line becomes its own block:

    1. Place the caret at the start of the line that should be aligned and press Enter (with EnterKeyResponse = Paragraph).
    2. Place the caret at the end of that line and press Enter again.
    3. With the caret still on the now-isolated line, click the alignment toolbar button.

    The middle line is its own <p> and is the only one affected by the alignment command.

    Letting the end user pick the mode

    Expose a single checkbox in your designer preferences - "Treat Enter as a line break (single paragraph mode)" - and bind it to the option. The change applies to future Enter presses only; existing content is not rewritten:

    chkUseLineBreaks.CheckedChanged += (sender, e) =>
    
    {
    
        htmlEditor1.Options.EnterKeyResponse = chkUseLineBreaks.Checked
    
            ? SpiceLogic.HtmlEditor.Abstractions.EnterKeyResponses.LineBreak
    
            : SpiceLogic.HtmlEditor.Abstractions.EnterKeyResponses.Paragraph;
    
    };

    The result

    A signature block built this way has each line in its own paragraph, with alignment applied per line - the way most users expect it to work.

    Ask your AI to do this

    Let your assistant do this for you. With the SpiceLogic MCP server connected, paste this into Claude Code, Cursor, or VS Code Copilot in agent mode.

    Using the SpiceLogic WinForms HTML Editor already referenced in my project, give my template designer control over whether Enter starts a new paragraph or only a soft line break, by exposing a checkbox labeled Treat Enter as a line break bound to Options.EnterKeyResponse, switching between EnterKeyResponses.Paragraph and EnterKeyResponses.LineBreak from the SpiceLogic.HtmlEditor.Abstractions namespace. Use this so a three-line signature block, for example a name, a title and a phone number, can have each line aligned independently once it lives in its own paragraph, instead of all three sharing one alignment because they sit inside a single paragraph joined by line breaks. Confirm the real EnterKeyResponses enum values and namespace with the SpiceLogic MCP tools before writing any code.

    Last updated on May 15, 2026

    Put this into practice.

    .NET WinForms HTML Editor Control ships with free C# and VB.NET sample projects and a 14-day evaluation.

    Prefer a guided look? Book a free live demo with our engineers - live on Zoom or Teams, never a chatbot.