Question about LF and <br>
-
Notepad++ v8.7.5 (64-bit)
Build time : Dec 21 2024 - 05:13:03
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : ON
Placeholders : OFF
DirectWrite : ON
Multi-instance Mode : monoInst
File Status Auto-Detection : cdEnabledNew (for current file/tab only)
Dark Mode : OFF
OS Name : Windows 11 Pro (64-bit)
OS Version : 24H2
OS Build : 26100.2894
Current ANSI codepage : 1252
Plugins :
mimeTools (3.1)
NppConverter (4.6)
NppExport (0.4)
Fellow Notepad++ Users,Could you please help me understand LF and <br>?
I have removed any CR and <br>tags in my HTML (this is in a table form)
When I copy my edited text into my (WordPress) page, save and review the draft there are still line breaks after each line:
Example: (What it looks like in Notepad ++
When I inspect it, a <br> has been inserted at the end of each line.I thought perhaps the LF is a <br>, but if I remove them all then the editor looses all the line numbering (and I have not found any other way to to wordwrap the text)
What am I not understanding?
-
@Saragrace-Knauf said in Question about LF and <br>:
Could you please help me understand LF and <br>?
LF (line feed) and CR (carriage return) are used in text files. Depending on which OS is using the file, there may be both, or just 1.
When you get to html files (yes I know they seem to be text files, but they have html formatting codes) you would use the <br>, <p>, <div> or other methods to break lines and produce paragraphs.
Notepad++ will disregard the <> html tags, showing them just as it does other text as it will work with the CR and LF to produce lines.
So in essence you need to understand more about html codes I think.
Terry
-
@Saragrace-Knauf said in Question about LF and <br>:
What am I not understanding?
Probably that a plain text editor (like Notepad++), the editor in WordPress, and HTML (what’s ultimately sent to a web browser to display as a web page) all have different conventions.
I haven’t used WordPress, but it’s likely that the editor you use to create your pages there has its own conventions about how to interpret line-ending signals. From what you’ve written, I think you might be copying from HTML, editing in Notepad++, then copying to and saving from WordPress. To do that successfully, you’d need to understand how each of those three manages line endings.
Notepad++ interprets CR, LF or CRLF in sequence as a line break. In the status bar at the bottom, you’ll see Windows (CR LF), Unix (LF) or Macintoch (CR); that tells you what Notepad++ will insert when you press the Enter key. (There are also a few operations that will not work correctly unless all the line endings in your file match whatever is set there.) You can right-click that to get a menu to change all line endings to a different one of the three choices. It is almost never a good idea to have mixed line ending types in the same file, or to have what’s in the file be different from what is shown in the status bar. (If you have mixed endings but what is shown is already what you want them all to be, just switch to something else and then switch back.)
HTML mostly ignores CR and LF. (There are exceptions in certain contexts, such as within <pre></pre> tags.) Most often you allow the browser to determine where line breaks should occur within paragraphs, and use tags like <p></p> or <div></div> to separate blocks of text. The <br> tag is used when you want to force a line break within a block (rather than, say, starting a new paragraph). Unless you know why you need to do that, don’t; use <p></p> tags to separate paragraphs, and let the reader’s browser work out where to break lines within paragraphs.
Finally, I don’t know how the WordPress editor works, but it probably has its own conventions. You’d need to learn about those from WordPress documentation, forums and support.
Edit to add: One other thing. If you’re just adding line endings in Notepad++ because you can’t read the paragraphs because they stretch way past the right edge of the window, turn on View | Word wrap.