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.

[Feature Request] Avoiding CSS manipulation of standard HTML elements

See original GitHub issue

Problem to solve

Currently, Vuetify changes some style properties of (very few) standard HTML elements, like p for example in /src/stylus/elements/_typography.styl.

While I understand the intention behind this, it adds a lot of issues and headache if used together with custom components or other libraries, which expect “default” (usually still reset) css styles for all standard HTML elements.

In conclusion, a non-Vuetify component may either be unexpectedly influenced because of these adjustments (which increases the maintaining cost for us, as we need to adjust preexisting components) or is (unnecessarily) entangled with Vuetify, even if it doesn’t use its components (but still has to address/reset these styling adjustments).

Furthermore, it also seems to be inconsistent, as for example $headings.h1 (within /src/stylus/elements/_typography.styl) is not bound to the h1 tag, but rather .display-4.

Proposed solution

As a solution, I would propose to use css classes to style all these elements, preferably prefixed with v- and to completely avoid opinionated styling of standard HTML elements. While there is usually some kind of styling like css resets involved, I assume that this is somehow a more common ground, many frameworks (whether other public library or internal components) can work with.

Given that this is without a doubt a mayor change, I believe the upcoming 2.0 release would be a great opportunity to introduce a cleaner css styling/naming convention, where all library-specific changes are within their own css class, preferable (even if not required to resolve this particular issue) prefixed with a v-.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
davydnorriscommented, Jun 2, 2020

This is very confusing right now.

I have just spent the past day tracking down why only some of my defined styles are not working after following the documentation to the letter, and after looking through the presets, and now I have read a bunch of bug reports that seem to indicate that the sass customisation for h1…h6 does not actually get applied to the header elements, but that they get added to the display-* classes?

It’s enormously confusing that the variables are still called h1…h6 but they don’t apply.

At the very least, can the documentation be clarified please?

1reaction
weotchcommented, Feb 19, 2020

I found a workaround for this using this PostCSS plugin: https://github.com/AoDev/css-byebye. I’m using Vuetify with Nuxt. Besides adding the package to my project, here’s what I added to my Nuxt config to get this to work:

{
  build: {
    postcss: {
      plugins: {
        'css-byebye': {
          rulesToRemove: [
            /\.v-application (p|ul|ol)/,
            /\.v-application \.(headline|title)/
          ]
        }
      }
    }
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling common HTML and CSS problems - MDN Web Docs
Some problems can be solved by just taking advantage of the natural way in which HTML/CSS work. Unrecognized HTML elements are treated by...
Read more >
[Feature Request] Adding a bottom margin to native lists ( ...
[Feature Request] Adding a bottom margin to native lists (ul, ol, ... where I asked to avoid CSS manipulation of standard HTML elements....
Read more >
HTML Styles CSS
CSS saves a lot of work. It can control the layout of multiple web pages all at once. CSS = Styles and Colors....
Read more >
HTML and CSS Tutorial: The Basics
Basic HTML and CSS Tutorial for the beginners.
Read more >
HTML Standard
1 Introduction; 2 Common infrastructure; 3 Semantics, structure, and APIs of HTML documents; 4 The elements of HTML; 5 Microdata; 6 User interaction ......
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