Learn something new every day
More Info... by email
In the HyperText Markup Language (HTML), a line break is a tag or cascading style sheet (CSS) property that causes the HTML viewer or web browser to immediately drop down 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 into a document. The first is to use the break (BR) tag, forcing the browser to start the next elements on the next line, aligned to the left border. The other option is to use different CSS properties to define borders, gutters or spacing around block-level elements to create open space, although this method does not affect word wrapping in a document.
One of the design principles of HTML is that the browser is usually allowed to have some control over the layout of web pages. This allows well-designed sites to have a very fluid appearance, regardless of the size of the display. When a paragraph is drawn, the browser is usually charged with finding the proper place to end a line, usually at the right margin of a block. Using an implicit HTML line break interrupts this process.
The BR tag is the simplest way to end a line and move down. Use of the tag is generally accepted for some minor formatting, although its use is frowned on as the sole way of defining paragraphs in a document. The paragraph tag is preferred for separating areas of text, because it creates a block that can manipulated with CSS or other tags, while the HTML line break tag stands alone and does not enclose a block. The break tag can be used within a paragraph block, largely to prevent the browser from using two breaks between paragraphs, which is the default behavior.
Another method used to cause a line break is to increase the size of a box of text with CSS properties. This effectively extends the bottom of a container so blank space is left after it. This can appear the same as using a break or paragraph tag, except the text within the container is not modified, so word wrapping is still largely controlled by the browser.
One area in which an HTML line break might need to be specified is when text is wrapping around an inline image. An easy way to create cleanly formatted paragraphs that sit to the side of an image is to use the CLEAR modifier for the HTML line break tag. This allows specification for whether a line break should continue as normal or jump to the next available line after an image. It also is possible to create CSS styles that will mimic this behavior, although it might not be as fluid under certain circumstances.