“I want to know how to break lines in programming”
“How can I break lines other than HTML?”
Don’t you think?
Even if you want to know how to break a line in programming, you will be worried about whether it is really right.
So, what kind of line breaks are actually available?
So this time
- How to break a line in programming “HTML”
- Points to note when changing lines
- How to break lines other than “HTML”
I will explain in detail about.
Read this article to learn how to break lines in programming.
Table of contents
- In programming “HTML” How to break lines
- 1. Utilize the “line break tag<br>”
- 2. Use the “paragraph tag <p>”
- Notes on line breaks in programming “HTML”
- 1. Tags change with version upgrade
- 2. Not tied to the information of one terminal
- How to prevent line breaks in programming “HTML”
- Summary: Using a programming language makes it easy to break lines
In programming “HTML”How to break lines
A line feed/paragraph code is required for line breaks in HTNML .
This is because even if you click the Enter key, it will not be a clean line break just by inserting a character space.
In order to break lines successfully, let’s use the following languages.
- Utilize the “line break tag<br>”
- Use the “paragraph tag <p>”
I will introduce them in order.
1. Utilize the “line break tag<br>”
When breaking lines in HTML, use “br”, which stands for BRreak.
You can create a single line break by typing next to the language you want to break.
I want a line break here. <br>
I was able to change the line.
As a point of caution,
- Using “br” in a row makes the code look messy
- Cannot be used at the time of termination
There are also disadvantages, so be careful when using it.
I want a line break here.
I want a lot of space between lines. <br>
This usage is not recommended due to its structure.
2. Use the “paragraph tag <p>”
It is also recommended to use the language of “p”, which is an abbreviation for Paragraph, to break lines.
The reason is that paragraph tags make the text easier to read.
For example, enclosing sentences in <p></p> makes them cohesive.
It can be said that the longer the character, the easier it is to check the line break at a glance.
I want a line break here.
A line break was successful.
In programming “HTML”Notes on line breaks
Here, I will explain what you should be careful about when doing line breaks in HTML.
- Tags change with version upgrade
- Not tied to the information of one terminal
If you are thinking of actually working on it, please refer to it.
1. Tags change with version upgrade
When inserting line breaks in HTML, make sure that the content of the tag has not been changed due to the version upgrade.
This is because a sudden change in the tag will be generated by updating it, and it will not be reflected on the browser of the personal computer.
Since the latest version is always updated, the following differences occur even with the same HTML.
- “<br>” in HTML4 and HTML5
- XHTML is “<br />”
Since there are such differences, be aware that the contents of the tags have not changed when the version is upgraded.
2. Not tied to the information of one terminal
After inserting line breaks, check not only on your computer’s browser, but also on various devices.
The reason is that not all terminals can necessarily use the “line feed tag<br>” .
For example, even if there is no problem on the browser of the personal computer, there are cases where the conversion is not displayed well when viewed on the smartphone.
In that case, it is better to reduce the number of line breaks or use the “paragraph tag <p>”.
When performing confirmation work, we recommend that you check a wide range of devices, not just one device.
In programming “HTML”How to avoid line breaks
In HTML5, there was a way to disable line breaks using “<nobr>”.
However, since it has been abolished in recent years, it is better to use “CSS”, a language for decoration, in order to prevent line breaks.
By using “white-space: nowrap”, it is possible to display without line breaks.
The line feed code is also used in programming languages other than “HTML”.
This is because line breaks in strings that are too long are not reflected by the “Enter key” for the same reason as HTML.
|mac (OS X)||\n|
|mac (before OS 9)||\r|
When using it, you will be able to break lines by inserting programming language between characters .
Summary: Using a programming language makes it easy to break lines
- Use “line break tag<br>” and “paragraph tag<p>” in HTML
- Be careful not to overuse the line break tag “<br>”
By using tags and programming languages, you can improve the readability of long sentences.
That said, the visibility and cohesion of the text on the browser will change depending on how line breaks are used, so use them according to the situation.