Hướng dẫn separate line in html
When you're writing HTML, you often need to insert line breaks. A line break is essential in addresses, poems, or when text exceeds the available browser width. If you don't insert your own line breaks, then the text gets formatted in an odd way. Nội dung chính In this tutorial, I'm going to show you how to insert line breaks in your HTML code with some "with and without" examples, so you can start using it correctly and format your text better. Basic HTML Line Break SyntaxYou can insert line breaks in HTML with the Be aware that HTML will ignore any line break from a keyboard’s return key.
If you are wondering why there’s a forward slash in the If you are using a code formatter like prettier, it'll always insert the slash when you save or paste even if you don’t put it in there. ADVERTISEMENT How to Insert Line Breaks in AddressesA line break is important when you're writing an address on a letter, for example, in order to format it properly. Here's an example of an address without line breaksAn address without line breaks (
I have added some CSS code to center everything with Flexbox and make the text a bit bigger:
This is how it looks in the browser: ADVERTISEMENT Here's an address with line breaksAnd this is how we can add line breaks to properly format our address:
It looks like this in the browser: How to Add Line Breaks to PoemsPoems are conventionally written in short breaking sentences in order to create visual hierarchies and format them nicely. So, if you want to write a poem in your HTML code, the ADVERTISEMENT A poem without line breaks
It looks like this in the browser: You can see the poem has no visual hierarchy, it is not formatted the right way, and so it is unreadable as a poem. A poem with line breaks
I also changed the font size a bit in the CSS:
It now looks like this in the browser: You can see that the poem is now more readable and formatted the right way. Some valuable advice: Do not use the You might be wondering – since the Well, it is possible. But there’s no real practical need to style it since all it does is create a couple of white spaces. ADVERTISEMENT ConclusionI hope this tutorial has given you the background knowledge you need to use the Thank you for reading, and keep coding. Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started |