What is an HTML line break?

In hypertext markup language (HTML), a line break is a Cascading Style Sheet (CSS) tag or property that causes the HTML viewer or web browser to immediately jump to the next available line and draw the next element, starting at the defined margin. There are two generally accepted ways to insert an HTML line break in a document. The first is to use the break (BR) tag, which forces the browser to start subsequent elements on the next line, flush with the left edge. The other option is to use different CSS properties to set borders, gutters, or spaces around elements at the block level to create open space, although this method does not affect word wrapping in a document.

The paragraph tag is preferred for separating areas of text, because it creates a block that can be manipulated with CSS or other tags.

One of the design principles of HTML is that the browser can usually have some control over the layout of web pages. This allows well-designed websites to look very fluid, regardless of screen size. When drawing a paragraph, the browser is usually tasked with finding the appropriate place to end a line, usually at the right margin of a block. Using an implicit HTML line break breaks this process.

The BR tag is the easiest way to end a line and go down. The use of the tag is generally accepted for some minor formatting, although its use is frowned upon as the only way to define paragraphs in a document. The paragraph tag is preferred for separating areas of text because it creates a block that can be manipulated with CSS or other tags, while the HTML line break tag is self-contained and does not include a block. The break mark can be used within a paragraph block, primarily to prevent the browser from using two breaks between paragraphs, which is the default behavior.

See also  What is a nested loop?

Another method used to cause a line break is to increase the size of a text box with CSS properties. This effectively stretches the bottom of a container so that there is white space after it. This could look the same as using a break or paragraph mark, except that the text inside the container is not modified, so the line break is still largely controlled by the browser.

One area where you may need to specify an HTML line break is when text wraps around an inline image. An easy way to create cleanly formatted paragraphs that sit next to an image is to use the CLEAR modifier for the HTML line break tag. This allows you to specify whether a line break should continue normally or jump to the next available line after an image. It is also possible to create CSS styles that mimic this behavior, although they may not be as smooth under certain circumstances.

Related Posts