Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stop BR tag breaking with CSS

Tags:

html

css

Is there a way to stop a <br> tag breaking using only CSS?

I tried br{display:none} whick works, but it also gets rid of the space between the two words, which I need to keep.

This is only for webkit (iPhone) so any CSS3 extravaganza is just fine.

I can't edit the content from the CMS, so simply removing the tag unfortunately isn't an option for me.

thanks!

like image 559
NathanBarley Avatar asked Feb 07 '13 12:02

NathanBarley


People also ask

Can we remove BR tag using CSS?

Solution: It is not possible to remove just <p> tags without removing content inside.

How do you prevent a line break in CSS?

Use white-space: nowrap; or give that link more space by setting li 's width to greater values. I prevented line break in li items using display: inline; . Maybe this will also help others with similar problems. Its important to be careful with display: inline as it can have side effects.

What can I use instead of Br in CSS?

There are many ways to break the line without using <br> tag. The used properties are listed below: white-space: pre; It is used to make elements acts like <pre> tag. display: block; It sets the display property of elements to block.

Can you use BR in CSS?

A line-break can be added in HTML, using only CSS, by employing the pseudo-class ::after or ::before . In the stylesheet, we use these pseudo-classes, with the HTML class or id, before or after the place where we want to insert a line-break.


1 Answers

Following on the answers here, this prevents the <br> tag breaking in both Chrome and IE:

br {     content: " ";     display: none; } 
like image 77
Shane K Avatar answered Sep 21 '22 18:09

Shane K