Cara menggunakan html new line
Tulis sesuatu tentang diri Anda di sini. Jelaskan secara singkat siapa Anda dan apa yang Anda lakukan untuk kehidupan Anda. Ingatlah untuk menggunakan teks tebal dan miring, untuk lebih memahami HTML lebih lanjut. Show
A line break, as the name implies, is a break in line 😅. A line break in HTML is a point where a line ends horizontally, and the next line starts on a new line. In HTML, when you write a string like this:
The whitespaces (the tab space before "Hello", the space between "am" and "trying", "a" and "new") will be ignored. The result on the screen will appear like this:
One way to fix this (though it's not very effective) is to create three
This will result in the following:
Because 0 elements, they occupy the entire horizontal space and the next element goes to the next line – as you can see from the result above.This solution is not effective because you have created three paragraphs. In cases where a screen reader is to interpret this, it will read it as three paragraphs instead of a single sentence. This can affect web accessibility. So how do you add a line break for an inline element? How to Add a Line Break in HTMLHTML has tags for numerous purposes, including to create line breaks. You can use the 1 tag in HTML to add line breaks. It can go between inline elements to break the elements into multiple parts.Here is an example of a paragraph with the 1 tag:
The 1 tag is a void element that doesn't have a closing tag. Instead, it is a self-closing tag.The above code results in this:
You can use this tag for other forms of inline elements like links. For example, look at this code:
Anchor tags, 4, are inline elements, so instead of the second link showing on the next line, it shows in the same line like this:You can use the 1 tag between the links to break the first link line:
ConclusionThe 1 tag in HTML starts the next element on a new line, similar to the carriage return 7 in strings.Instead of using block elements for putting elements in new lines, you can use the line break tag: 1.In cases like sentences, using the 1 tag serves as a visual line break and doesn't affect accessibility. Screen readers will read the sentence as it is without pause.ADVERTISEMENT ADVERTISEMENT ADVERTISEMENT Developer Advocate and Content Creator passionate about sharing my knowledge on Tech. I simplify JavaScript / ReactJS / NodeJS / Frameworks / TypeScript / et al My YT channel: youtube.com/c/deeecode If you read this far, tweet to the author to show them you care. Tweet a thanks Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started Elemen Global AttributesAtribut Secara Global (Keseluruhan)
Silahkan, lihat referensi mengenai HTML Global Attribute Event AttributesAtribut event (Peristiwa)
Silahkan, lihat referensi mengenai HTML Events Attribute ExampleContoh HTML |