Coder Social home page Coder Social logo

Comments (2)

sentience avatar sentience commented on May 9, 2024 3

a (and a:link, a:visited) matches all links, whether they have a class attribute or not.

a[href]:not([class]) matches only links with no class attribute. This is often preferable because you can assign specific styles for those “ordinary” links without having to then override those styles to remove them from your “specialized” (classed) link styles.

For example, if you wanted your class-less links to be bold, but your classed links to be normal, you could write:

a { font-weight: bold; }
a.someclass { font-weight: normal; }
a.anotherclass { font-weight: normal; }
a.thirclass { font-weight: normal; }

…or you could just write this one rule:

a[href]:not([class]) { font-weight: bold; }

Note: If you aren’t concerned about a elements that aren’t links (i.e. old-school <a name> anchors), then you can omit the [href] and go for a:not([class]).

from css-protips.

fabian-mcfly avatar fabian-mcfly commented on May 9, 2024

Mind giving some real examples and not some constructed, theoretical stuff?
If dropping IE < 9 support is considered a "pro tip", then I happily stay non-pro.

And I just don't get the whole reasoning behind this collection of tips.
Reducing multiple resets to "default"-styles is the only justification for this "tip" to be valid; while the lobotomized owl selector forces you to reset the top margin all the time if you don't need it. That's just inconsistent reasoning.

from css-protips.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.