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.

Missing space between HTML elements

See original GitHub issue

Version

2.5.17

Reproduction link

https://github.com/revolter/website/tree/demo/missing-space-bug

Steps to reproduce

Run the app and navigate to the about page.

What is expected?

A space between the abbr and code tags as in the About.vue file.

What is actually happening?

The mentioned space is missing when rendered in the browser.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
sqalcommented, Nov 3, 2018

Whitespace characters between HTML tags are removed because preserveWhitespace option in vue-loader is set to false by default in vue-cli, here: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/config/base.js#L87. In order to enable this option you have to modify webpack config using either chainWebpack or configureWebpack in your vue.config.js.

https://cli.vuejs.org/guide/webpack.html#chaining-advanced

The first one is simpler imho, actually here’s what you need to do:

vue.config.js

module.exports = {
  chainWebpack(config) {
    config.module
      .rule('vue')
      .use('vue-loader')
      .loader('vue-loader')
      .tap(options => ({
        ...options,
        compilerOptions: {
          ...options.compilerOptions,
          preserveWhitespace: true,
        },
      }));
  },
};
2reactions
pmrotulecommented, Mar 31, 2021

Quick tip if you really need a space to be present between particular tags… you can always explicitly insert one using the   HTML entity.

e.g.

<span>lorem</span>&#32;<span>ipsum</span>

You can also explicitly insert one using mustache:

<span>lorem</span>{{ ' ' }}<span>ipsum</span>
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove the space between inline/inline-block elements?
Applying a margin-right: -4px to the inline block elements will remove the spacing and is supported by all browsers. See the updated fiddle...
Read more >
How to fix: No space between attributes. - Rocket Validator
Attributes in HTML elements need to be separated by space, in this example the first line is invalid and the second one is...
Read more >
4 Easy Ways to Insert Spaces in HTML - HubSpot Blog
Learn how to insert multiple spaces in a row in HTML, how to add breaks between lines, and how to easily add whitespace...
Read more >
Fighting the Space Between Inline Block Elements | CSS-Tricks
Fighting the Space Between Inline Block Elements · Remove the spaces · Negative margin · Skip the closing tag · Set the font...
Read more >
How to remove spaces between html elements (when margin ...
Solution 1 ; div style · margin: 0; display: inline-block; float: left;" ; style type · text/css" ; div class · nospaces" ...
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