question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Space between two HTML tags

See original GitHub issue

I’ve noticed that if you put a space between two HTML tags such as a space, it is interpreted as a content and insert a new line.

For Example: (Focus on the breaking lines, not styling)

render() {
  const htmlContent = `<p>Hello</p> <p>There</p>`;
  return (
     <HTMLView
        value={htmlContent}
     />
  );
}

It will render something like : screen shot 2018-01-29 at 18 53 06 (Two breaking lines)

When the render should be like : screen shot 2018-01-29 at 18 53 22(One breaking line)

I think that in general, it’s an issue about interpreting some content that are not between HTML Tags Take another HTML such as : const htmlContent = `<p>Hello</p>tot<p>There</p>`;

It renders like : screen shot 2018-01-29 at 18 58 51(One breaking line)

While it should be something like : screen shot 2018-01-29 at 18 59 03(Breaklines between each content)

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:13
  • Comments:13

github_iconTop GitHub Comments

17reactions
ducpt2commented, Apr 4, 2018

@miniofskidev This did the magic for me: data.replace(/(\r\n|\n|\r)/gm, “”)

15reactions
donni106commented, May 22, 2018

@nguyenhuyhieu1995 there are probably new lines between you HTML tags, which normal browsers are ignoring but the HMTLView is not. I think you need a trim method, like @ducpt2 was mentioning, where rendering the HTMLView:

data.replace(/(\r\n|\n|\r)/gm, "")
<HTMLView
    value={`<div>${data.replace(/(\r\n|\n|\r)/gm, "")}</div>`}
    renderNode={renderNode}
/>

This is working for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to have space between two <a> tag in the same div
The <&nbsp> tag creates a space that does not break into a new line. Two words that are separated by a non-breaking space...
Read more >
How to Create Extra Space in HTML or a Web Page
To add extra space below a line or paragraph of text, or push text down lower on the page once, you can use...
Read more >
How do I add space between two elements in HTML? - Quora
If you want to make spaces between two inline elements/words then use   if required multiple spaces use this multiple times. If you...
Read more >
Add Space in HTML - Instructions - TeachUcomp, Inc.
To insert blank spaces in text in HTML, type   for each space to add. For example, to create five blank spaces between...
Read more >
5 Ways to Insert Spaces in HTML - wikiHow
1. Open your HTML code in a text editor. You can use any text editor, such as Notepad for Windows, or TextEdit for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found