Comments (13)
@DanGamble89 I appreciate the feedback but I have to disagree. The additional specificity is negligible and one of the reasons I'm advising it is that the use of :not(:last-child)
is very clear with the CSS selector defining the border the way a human would describe it.
from css-protips.
I wouldn't say it's negligible. Once you start having to style dropdowns on the same nav or style it different on mobile where there are no borders then you will hit conflicts. I use to be an advocate of this method but once you start implementing these things it just causes headaches.
If you have to style the asset responsively i'd go for child specific pseudo's as opposed to hitting all of them with a :not
from css-protips.
I think if you're supporting IE, stick to using classes and learn more than CSS. Not a good "PRO" tip.
from css-protips.
I think if you're supporting IE, stick to using classes and learn more than CSS. Not a good "PRO" tip.
+1
from css-protips.
I think if you're supporting IE, you should know that IE has supported :not since IE9.
http://caniuse.com/#feat=css-sel3
from css-protips.
I'm very much aware of that, thank you. I don't see the point of this PRO tips, honestly. I feel like avoiding selectors may even be a better practice.
I am aware there are probably no performance issues now.
from css-protips.
I'd say using selectors is bad practice too, stick to classes 100% unless you can't
from css-protips.
I'd say using selectors is bad practice too, stick to classes 100% unless you can't
Not sure if srs. The new CSS3 selectors are there so we can strip the HTML markup of unnecessary classes to make it cleaner and to further separate content from style. I have to say I like both the nav and inline list :not()
tip. I wasn't aware of the :not()
selector before.
from css-protips.
I'd say using selectors is bad practice too, stick to classes 100% unless you can't
@DanGamble89 So what about if I want to style the first and/or last elements of a list differently? Should I add first
and last
classes instead of using selectors, because it "can" be done that way?
from css-protips.
Using pseudo selectors is fine, using HTML selectors i.e, div, span, h1 is bad practice.
:first-child
, :last-child
are totally fine. :not()
can be okay as well. But in instances like this it's bad as it adds an extra level of specificity for little to no gain. It will cause you problems when you want to style dropdowns in the navigation or make the navigation responsive
from css-protips.
@DanGamble89 then just don't use them for dropdowns!
Styling div
s may not be advisable since a div
is fairly generic but styling h1
is just fine!
from css-protips.
It will cause you problems when you want to style dropdowns in the navigation or make the navigation responsive.
@DanGamble89 how so? Do you have an example of that so we can see if :not()
is really the problem?
from css-protips.
styling h1 is just fine!
@vwochnik agreed, especially when you have to consider accessibility.
from css-protips.
Related Issues (20)
- Some misunderstandings about adjacent sibling combinator (+) as alternative way of using :not() pseudo-class HOT 4
- Different language HOT 1
- [Suggestion]CSS for ebooks
- Translations HOT 1
- Animation to any element HOT 5
- Edge now supports "all" keyword HOT 1
- Add tip: wrapper utility HOT 2
- good jop
- Add tip: Using Aspect Ratio instead of usual Margin and Padding HOT 6
- Add tip: Adding CSS Libraries like bootstrap and making this repo more elaborate. HOT 1
- Css pro tips
- Suggestion: Turn this collection of tips into a github pages site. HOT 1
- Max Function for Max-Width HOT 1
- How do I overlay an image over the background one ? HOT 4
- How to wrap a title into respective multiline headings.? HOT 1
- Placeholder Selector HOT 2
- List of links, can't add style with CSS HOT 1
- Add responsiveness with Key Frames HOT 6
- Readme upgrade HOT 3
- Css pro tips
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from css-protips.