How to remove line breaks on tablet and mobile using Elementor and CSS

Creating custom line breaks gives you full control over how the headlines or paragraphs look like on your website. In this post, we will see how to create and remove line breaks on tablet and mobile devices in Elementor and CSS.

Using line breaks can be an effective way of organizing your text to make it look more impactful, visually appealing and legible. Line break means simply splitting a line of text into two lines without actually creating a new paragraph. Take a look at this example from this website’s homepage where I’ve used line breaks to organize the main paragraph of text in the way I want:

However, sometimes you want these line breaks to appear only on desktop and you want to hide them on tablet and mobile to avoid unwanted breaks inside of paragraph when viewed on smaller screens. Let’s see how to create line breaks in Elementor and how to make them appear only on certain devices.

Check the video below or continue reading!

Download Elementor Pro here.

*This post may contain affiliate links. If you click on a link and make a purchase, I will receive a commission from the sale, with no extra cost to you. That way you are supporting my blog and allowing me to keep making videos and posts like this. I only promote products that I use, have experience with and support, such as Elementor Pro.

How to create a line break in Elementor

To create a line break (not a paragraph break), when you place a text editor in Elementor, all you need to do is click ‘Shift+Enter’ where you want your line break to appear. This will break the text and create a separate line, but still treat those lines as part of the same paragraph.

How to remove a line break in Elementor and CSS on tablet or mobile

When you create a line break using ‘Shift+Enter’, there is a so-called ‘br’ tag that gets automatically inserted in the code. In order to remove it, you simply need to hide this tag and target the devices or screen widths where you want to hide it.

If you have Elementor Pro version (paid one), you can do this simply by :

  1. Clicking on the text editor
  2. Going to the ‘Advanced’ tab under Custom CSS field
  3. Target the media that you want to apply this change to
  4. Hide the ‘br’ tag using ‘display: none‘. Don’t forget to include the ‘selector’ tag to tell Elementor to apply this styling to the element you selected. Finally, in order to apply this hiding property to the ‘br’ tag, simply add ‘br’ after selector. So the code might look like this:
@media (max-width: 1023px){
  selector br{
  display: none;
  }
} 

Download Elementor Pro here.

*This post may contain affiliate links. If you click on a link and make a purchase, I will receive a commission from the sale, with no extra cost to you. That way you are supporting my blog and allowing me to keep making videos and posts like this. I only promote products that I use, have experience with and support, such as Elementor Pro.

To do this in Elementor free version, you can use the same principle. However, since there is no Custom CSS field, you would need to insert the code through a plugin. Simple custom CSS and JS plugin will do the trick. After this, instead of selector, you can use the class name that the element belongs to. For example, if you have assigned the class ‘body-copy’ to your text in Elementor, use this class to apply ‘display: none’ property to its ‘br’ tag. Don’t forget to keep the @media part of the code to target the mobile and tablet devices only! And of course to call out the class with a ‘.’ in front of its name.

@media (max-width: 1023px){
  .body-copy br{
  display: none;
  }
}

You can apply the same principle if you assigned an ID to your element, not a class.

Alternatively, if you don’t want to apply these changes to a global class in CSS, you can simply target the specific element and apply these changes just to this single element, instead of the entire class. In order to target it, you can use Inspect element feature.

That’s it! Now you can have full control over how your most important text and messages look like across all devices.

*This post may contain affiliate links. If you click on a link and make a purchase, I will receive a commission from the sale, with no extra cost to you. That way you are supporting my blog and allowing me to keep making videos and posts like this. I only promote products that I use, have experience with and support, such as Elementor Pro.

Share this post:

Leave a Comment

Related posts:

General instructions:

  1. Open the exercise in your browser and read the task and the content on the left side of the screen. 
  2. You will be editing the content on the right side of the screen.
  3. In order to do that, right click on the exercise page that you opened and go to ‘Inspect’.
  4. Go to ‘Sources’ in the top bar and if you cannot see an empty CSS sheet where you can type the code, press Ctrl + P and start typing ‘styl’ in the search bar. Then press enter to open the CSS sheet.
  5. Follow the notes on the left and start typing your CSS code to see the changes online!
  6. Important! Do not refresh the page while you are editing the code, as these changes are in preview mode only and you can see them immediately, as soon as you write a line of functioning code.
  7. Use the custom classes in the notes on the left side of the screen, as well as ‘Elements’ on the top bar of the ‘Inspect’ to target and style the classes and elements. For example, you can enable the small icon on the top left of the ‘Inspect’ window (‘Select an element in the page to inspect it’) to find the default class name of the element you want to edit, while you are in the ‘Elements’ tab.

Tips:

  1. If the code is not showing any changes, try adding the !important tag at the end of the line before closing it (before the “;” symbol) and see if it works then.
  2. Don’t forget there are usually more ways to achieve the same result. Be creative!
  3. If you get stuck, write your email address in the form on the left side of the screen and you will get the solution (CSS code) in your email.

Sources:

  1. You can find a lot of tutorials on my youtube channel. 
  2. Watch the tutorial on how to solve these exercises here.

Please check your email and stay tuned for updates on the course.

We will notify you shortly when it’s available for presale.