A rather geeky/technical weblog, est. 2001, by Bramus

CSS @​supports rules to target only Firefox / Safari / Chromium

Yesterday I took some time to rework my Houdini-powered CSS Gradient Border Animation Demo to include a fallback for non-Houdini browsers.

The plan of attack was pretty straightforward:

  • Manual frame-by-frame animations for non-Houdini browsers
  • Automagic Houdini-powered animations for browser with @property support

Only problem with that approach is that there’s currently no way to use @supports to directly detect whether a browser supports Houdini’s @property or not , so I got creative with @supports …

Houdini is a set of low-level APIs that exposes parts of the CSS engine, giving developers the power to extend CSS by hooking into the styling and layout process of a browser’s rendering engine. Houdini is a group of APIs that give developers direct access to the CSS Object Model (CSSOM), enabling developers to write code the browser can parse as CSS, thereby creating new CSS features without waiting for them to be implemented natively in browsers.

It really is magic, hence it's name Houdini. I'd recommend this slidedeck and this video to get you started

Join the Conversation

' src=

  • Pingback: Web Design & Development News: Collective #668 | Codrops

Hi Bramus, it looks like this is not working. I have both Brave (Chromium) and Safari open next to each other on my desktop and the “combined demo” are both showing blue.. (Safari should be red?). Has something changed with the specs on either of these browsers since 2021?

As mentioned in the post, these tests are really fragile and could stop working any time. I guess that time has come, as more browsers support many new features.

Leave a comment

Cancel reply.

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.

This site uses Akismet to reduce spam. Learn how your comment data is processed .

Blackhole Pro

  • Better Image Preloading with CSS3
  • Margin Offset for Anchor Targets with CSS or JavaScript
  • The Art & Science of Folding CSS Code
  • Understanding CSS3 and CSS2.1 Border Properties
  • Visual Walkthrough of @font-face CSS Code

Target iPhone and iPad with CSS3 Media Queries

When designing a website, it’s always a good idea to test on as many different platforms, devices, and browsers as possible. These days, pimping your websites for the iPhone and iPad is an important step in the design process. Especially on the iPad, sites tend to look about 20% cooler than on desktop browsers, so you definitely want to take the time to fine-tune the details. And when dealing with iDevices, it’s often necessary to deliver some custom CSS to make everything just right.

Want to apply CSS styles to the iPad and iPhone? Here is the plug-n-play, copy-&-paste code that actually works.

As you may have heard , I’ve been super-busy behind the scenes building an Angry-Birds fan site, of all things. The site is looking great so far, but needed some tweaking to appear slick on the iPad and iPhone. After testing a number of different solutions, here is what I found that actually works ..

Target iPad & iPhone with separate CSS files

If you want to apply styles to the iPad and iPhone using external stylesheets, put this code in your <head> :

For this to work, you need to edit the path to each of the stylesheets. Then add some styles exclusively for the iPhone ( first <link> ) or the iPad ( second <link> ).

How does it work? Well, we first exclude IE by wrapping the links in a simple conditional comment . Then we’re using some CSS 3 media queries to target each device specifically. Safari on the iPhone responds to a max-device-width of 480px , and Safari on the iPad seems to respond best when both min-device-width and max-device-width are used in the query. Together, these media queries apply styles in either portrait or landscape orientation.

Target iPad & iPhone from within your existing stylesheet

Using external stylesheets to target iStuff works great, but the extra HTTP requests can reduce performance. To avoid this, we can apply iPad/iPhone-specific CSS using our existing stylesheet. You know, the same one that we’re using for Firefox, Opera, and other desktop browsers. After much experimentation and testing, here is what I found that works :

Just place that code into your stylesheet and change the declaration blocks to something more useful. Unfortunately, combining these two media queries won’t work :

As always, comments, questions, and suggestions are welcome! :)

' src=

37 responses to “Target iPhone and iPad with CSS3 Media Queries”

' src=

Very cool, thanks so much for sharing this code. Is this to say that we could simply include these styles in our existing WordPress theme stylesheet and our sites would be formatted for iPhone or iPad?

Would doing this exclude the need for plugins like WP Touch?

' src=

Jeff wouldn’t it be easier to check the user-agent string for iPhone/iPad? Then you can spoof your browser to do testing as not everyone has an iPhone/iPad to test on.

' src=

@Adam: Yes, the media queries could be used in your theme stylesheet to apply any styles to iPad/iPhone Safari browser. With CSS, we can change site appearance, but not structure. You can customize things using CSS , but for major structural overhaul, it’s way easier to go with WPtouch (or whatever).

@Skye: For development sites, sure – by any means necessary. But for production sites, delivering targeted styles in existing CSS files is going to save HTTP requests and help optimize performance. So once you finalize your iCSS, just add it to your main stylesheet using the code above.

' src=

I’ve created an Apple Stylesheet with iPhone specifc styling:

http://pastebin.com/Y2BsXig4

It’s clear and simple and targets older versions of Apple products.

' src=

How does “ only screen and (min-device-width: 768px) and (max-device-width: 1024px) ” only target the iPad? Won’t it target any device whose screen width is between 768px and 1024px (including normal browser windows)?

@Jeff: Thanks for the clarification and the additional link, it’s most appreciated.

' src=

For the last code example to work could you just miss out the second ‘@media’? So it reads ‘@media only screen and (min-device-width: 768px) and (max-device-width: 1024px), only screen and (max-device-width: 480px) { }’? I have not used css3 media queries before, and may have misread this page http://www.w3.org/TR/css3-mediaqueries/ (example VI).

@Deano: Thank you for sharing! :)

@Daniel15: Never said it “only” targets anything – of course these media queries will also match any device that meets the criteria. For the iPad, we’re getting pretty specific with the “ and ” qualifier, so the matching device (not browser) would have to have the same screen dimensions as the iPad. I’m sure there are such devices, but I have yet to hear of one.

@Adam: Anytime – happy to help! :)

@Andrew: Perhaps so.. I will test this tonight and update the post if positive results are achieved. Thanks for pointing it out.

' src=

great i never thought media attribute would be so helpful to filter the browser before

' src=

The media query for iPhone is valid for iPhone Geneartions 1-3, but will it work with Generation4 handsets, too? AFAIK the retina display has a physical resolution of 960×640, but how does it behave concerning the media queries?

At the moment I don’t have access to a Gen4 Device, any body out there to report on this issue?

Kind regards, mtness.

' src=

To be clear, can I just drop the code you’ve mentioned into my existing stylesheet and be good-to-go?

You said something about useful declarations but I didn’t really get that…. :-(

@Avi D: yep just drop it in

Here’s the latest version of my sheet that is a great starting point:

http://pastebin.com/VYMeKqtV

css exclude safari

  • more »
  • mod_rewrite
  • optimization
  • Online Dev Tools
  • About Perishable Press
  • Perishable Press Archives
  • Contact Perishable Press
  • Welcome to Dungeon!
  • Wizard’s SQL Recipes (eBook)
  • The Tao of WordPress (eBook)
  • Digging Into WordPress (eBook)
  • Develop WordPress themes (eBook)
  • WordPress on shared hosting (video tutorials)
  • .htaccess made easy
  • Code Snippets
  • Blackhole Pro

How do I hide elements from Safari (or any browser)?

I’m using a page load animation on my site. It works great on Chrome but lags and doesn’t disappear on Safari. I’m looking to hide the element entirely from Safari. I know there is a way to do this, I imagine it is a CSS affair. Any ideas?

Hey Tucker,

Whilst I would always recommend developing cross-browser compatible CSS and site code, there are ways to target only the Safari browser.

This Stack Overflow thread should help:

I hope that helps!

Cheers, Logan

Thank you for your help! I wish Safari didn’t have these issues with page load animations, especially since nothing in the animation has an auto value. I will try this code!

Would you have a recommendation of where to implement this? In the before < body >?

Best, Tucker

No problem - happy to help!

I would go ahead and place this type of code in the tag of the applicable page/pages. If you need it site-wide, then you can apply it via your project’s Custom Code tab on the Dashboard.

Hope that helps.

Related Topics

Change CSS rules only in Safari

FabioRosado Saturday 5th, May 2020 2 mins to read 0 Like 0 Comment

How to apply css rules to safari only

The solution.

While working on Thumbs Up News , I've noticed a strange UI bug that happened only on Safari, when the screen was smaller than 900px height-wise. All the other browsers where okay, but the subscribe button was broken. The border was pushed up outside the area of the button and was now between the two elements of the menu. This only happened when a user clicked the categories button and the sub-menu expanded. I'm assuming that this happens because Apple wants space for its bottom menu?

The mobile menu is set on a fixed position. It seems that Safari will change either the padding, the margin or just some border rules when that fixed element doesn't have enough space vertically to show some space under the last element. My first thought was to use the -webkit rule to increase the padding on the button. Using that rule fixed the issue on Safari but broke on Chrome and this is when my search on how to apply CSS rules to a specific browser started.

After searching for a while, I've come across this article written by Ryan - CSS3 Media Query to target only Internet Explorer (from IE6 to IE11+), Firefox, Chrome, Safari and/or Edge , if you scroll down you come to this little hack that works on Safari 10.1+.

I am using Sass on Thumbs Up News and that means I can't have an empty @media rule. But this was a great starting point for coming up with a solution. I've removed the empty media query to see if the rule would work on Safari and not on any other browser. Surprise, surprise, it worked! Now I decided to play around with the media query rule a bit more, to see what works and what doesn't work.

The Safari only rule hack has two parts. You need to use a unit that is not supported by Safari - dpcm , dpi , dppx and you need to set that media query to not all . The not all rule is important so chrome doesn't pick it up.

After testing different things and playing around with the media query, I've come to the final solution. I've also added a rule to trigger the CSS only when the screen is smaller than 900px high, because we don't want the menu to be broken on a larger screen.

That's all there is to get a media query work on Safari only. I'm still wondering why this trick works and would love to know why, so if you know the answer please let me know!

Webmentions

You might also like these.

A lot of sites make the first letter of a paragraph spread to multiple lines, let me share with you how you can do it.

Make the first letter spread multiple lines

Make the first letter spread multiple lines

Nx makes it easy to work with monorepost, this article will show you how you can use Nx for your projects and talks about some basic commands that will help you.

Getting started with Nx

Getting started with Nx

How to set up an UI element persistent in Gatsby to allow users from Landing in Tech to listen to the latest episode, when navigating the site.

How to make a UI element persistent in Gatsby

How to make a UI element persistent in Gatsby

How to create a function to filter articles by tag. On this post I am using the javascript filter method to filter all articles.

How to filter all MDX articles by tags

How to filter all MDX articles by tags

CSS Reference

Css properties, css :not selector.

Set a background color for all elements that are not a <p> element:

Definition and Usage

The :not( selector ) selector matches every element that is NOT the specified element/selector.

Browser Support

The numbers in the table specifies the first browser version that fully supports the selector.

Get Certified

COLOR PICKER

colorpicker

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail: [email protected]

Top Tutorials

Top references, top examples, get certified.

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Browsers ignoring CSS?

I have this in a CSS file:

On MacOS, Safari honored the margin but ignored font-family and font-size. I tried it in Firefox, and the font-family and margin were honored.  Changed "50" to "150" in both places, and in both browsers opened the CSS file itself (i.e., made the browser display the actual contents) and clicked refresh.  Saw the contents change.  Went to the HTML page and clicked refresh.  Neither side changed.

Closed both browsers, moved both CSS and HTML to a different URI. Opened Safari and removed all cache and cookies.  Opened Firefox and pointed both browsers to the new location.  No change in font-family, margin, or font-size.

There is no inline style in the HTML. There are no other mentions of these three attributes in the CSS.

Is there something wrong with my CSS syntax?

(Tried to put this on superuser SE but the captcha is broken.)

WGroleau's user avatar

  • 1 This might be a better question for Stack Overflow ( stackoverflow.com ). –  Peter Nielsen Commented Apr 12, 2022 at 0:36
  • you missed the unit in case of margin, it should be 50px, or I will recommend you to use rem unit by converting px into rem, I use pxl2rem.com/px-to-rem myself. –  Prashant Singh Commented Nov 30, 2023 at 13:46

Units? I assume you want px.

em, ex, %, px, cm, mm, in, pt, pc, ch, rem, vh, vw, ect are possible units.

Inline style would be, (but please don't):

For readability (and for the love of humanity) of the document (using inline style means the person looking at the code if they need to change it will spend a lot of time figuring it out), inline style should almost never be used.

On margins there are collapsible margins that sometimes or under some circumstances don't. I pity anybody trying to debug margins with them being set via inline style.

Wayne Smith's user avatar

  • I'll have to test of course, but I'm fairly certain you've spotted my mistake. –  WGroleau Commented Apr 29, 2022 at 5:08
  • +1 for inline comments. Drove me nuts on a web team when we were required to use an HTML generator. When it failed (often!) having to debug HTML with no line breaks, tons of inline style tags, font change elements opened and closed with no content between, tables used for some of the formatting, etc. … –  WGroleau Commented Nov 30, 2023 at 18:15

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged safari fonts firefox css ..

  • Featured on Meta
  • Announcing a change to the data-dump process
  • Upcoming initiatives on Stack Overflow and across the Stack Exchange network...
  • We spent a sprint addressing your requests — here’s how it went

Hot Network Questions

  • Roasting vegetables instead of sweating for a stock
  • Can you use the Monster's of the Multiverse Hobgoblin's Fortune from the Many feature multiple times on the same saving throw?
  • Does color temperature limit how much a laser of a given wavelength can heat a target?
  • If the sleep time of a function at first time differs from the second time, but the output is the same, is it still a idempotent function?
  • Is the XOR of hashes a good hash function?
  • What is the name of this location in the Gerudo Highlands, at the top of a mountain?
  • Was supposed to be co-signer on auto for daughter but I’m listed the buyer
  • The Zentralblatt asked me to review a worthless paper, what to do?
  • Use a single Image Texture node with multiple mappings
  • Is the ‘t’ in ‘witch’ considered a silent t?
  • From what equations is magnetic field uniquely determined for a given current distribution?
  • What are the ways compilers recognize complex patterns?
  • Citing specific R functions in publications?
  • Why not use computers to evaluate strength of players?
  • How could warfare be kept using pike and shot like tactics for 700 years?
  • How to choose a textbook that is pedagogically optimal for oneself?
  • Natural mechanism behind burning oceans
  • Zugzwang where the side to move must be mated in exactly 2 moves
  • How were the alien sounds created in the 1953 War of the Worlds?
  • A Comprehensive Masterpiece on History of Science
  • What happens if a leading Presidential candidate dies with no running mate?
  • When Éowyn secretly followed Théoden as Dernhelm, who was in charge of the Rohirrim?
  • Connected counters
  • Can an employer use your FMLA “tardiness” from a previous time working for them in a re-hire situation?

css exclude safari

Instantly share code, notes, and snippets.

@rcolepeterson

rcolepeterson / cssForIpad.css

  • Download ZIP
  • Star ( 0 ) 0 You must be signed in to star a gist
  • Fork ( 0 ) 0 You must be signed in to fork a gist
  • Embed Embed this gist in your website.
  • Share Copy sharable link for this gist.
  • Clone via HTTPS Clone using the web URL.
  • Learn more about clone URLs
  • Save rcolepeterson/2024545 to your computer and use it in GitHub Desktop.

Controls the level of style and functionality of the site, a lower fidelity meaning less bandwidth, battery, and CPU usage. Learn more .

Custom Style Sheets in Safari

I first heard mention of adding a custom style sheet in Safari a couple months back. I honestly can’t remember where I saw it but I was reading something and, in passing, the author mentioned the idea of hiding the right sidebar on Twitter using a custom style sheet in Safari. This thing:

Screenshot of the right sidebar of twitter.com, circa Jan 2021.

It’s funny how you sometimes miss the entire point of someone’s writing and selectively remember what you want, in this case “hey, I can hide that dumb module on Twitter with little effort?” I’d like to say that I have the self-discipline to avoid clicking on anything in that module, but unfortunately I am not that strong of a person. Sometimes I just get bored and something there makes me think “oh, hmm, I wonder...” and then I click it. It’s one of those things where, if it wasn’t there, it wouldn’t be a problem. Like keeping cookies right next to your desk. But it’s frictionless and easy and RIGHT THERE that I succumb. But I digress. My weaknesses are not on trial in this post.

The thought hit me: “hey I should hide that right sidebar on twitter.com using a custom style sheet in Safari!” So I did. And then I moved on with life. I never thought to write a post about it because, you know, custom style sheets in a browser? That’s old news.

But then, I recently found this post published in November of 2020 about customizing your browsing experience using custom style sheets and thought “I guess this isn’t old news just quite yet.” Plus I’m trying to write a lot more this year , so here we are.

Note: it’s worth mentioning that hiding the right sidebar in twitter isn’t a novel idea. Craig Hockenberry created a Safari extension that’ll do it for you called “Fixerrific”. Granted, like my custom style sheet, this removes the entire right sidebar, including the search box which you might actually find useful. That said, you can still access the search functionality on twitter by going to the Explore tab.

How I Did It

First off, Safari lets you specify a custom style sheet.

Screenshot of Safari’s preferences pane where you can select a custom style sheet.

In case you don’t know, a custom style sheet is a bunch of CSS rules that you get to specify and then the browser will apply them to every single web page you visit .

The first thing I needed to do was open twitter.com and find out what type of CSS rule I could write to target that right sidebar. I can tell you, it wasn’t easy. Twitter has a bunch of generated classes names, which I’m assuming are quite dynamic, so finding a rule that would target the right sidebar and not change in the near future seemed like it might be tough. But then I found it: a DOM node which encompassed the entire right sidebar that had a very specific attribute data-testid="sidebarColumn" .

Screenshot of twitter.com in Safari with the developer tools open and targeting a parent DOM node of the right sidebar.

I can’t say for sure, but that looks like one of those attributes the QA team appends to certain elements they want to find with their automated browser tests. The whole purpose of those kinds of attributes is so the engineers won’t touch them and change their names, that way the automated tests can run for a long time without breaking. Again, I can’t make any guarantees, but this selector will probably be around for a while. So I felt pretty confident I could use that selector and not have it break in a short period of time due to twitter refactoring their DOM markup.

Once I had a selector I could use, I opened my text editor and created the following CSS file:

From there, I saved the .css file in my Dropbox folder (for backup purposes, i.e. a lazy man’s version control) then opened Safari’s preferences and selected my newly created file. A restart of Safari and boom! The sidebar was gone.

Feeling emboldened and empowered with my CSS sword of righteousness, I figured I’d go ahead and get rid of the DM/chat widget thing twitter recently introduced. It was merely visual noise to me. And fortunately, it had a similar way to be targeted: [data-testid="DMDrawer"] .

Screenshot of twitter.com in Safari with the developer tools open and targeting a parent DOM node of the right sidebar.

Pretty cool. Now I have a version of twitter custom tailored to me, free of a lot of distractions I don’t want to see.

Screenshot of twitter.com in Safari with a custom style sheet applied that hides the sidebar and the DM widget in the bottom right.

Observations Nobody Asked For

If you write a lot of custom styles for sites across the web, you could start running into naming collisions. It would be neat if you could scope styles to a specific domain. Maybe there’s a way to do it? I couldn’t think of one. Imagine:

JavaScript has access to a page’s URL via window.location but AFAIK that’s not available—at least not in any standardized way—in CSS.

It's likely a terrible idea, but we have custom user style sheets, is there such a thing as a custom user scripts? Imagine giving a .js file to the browser and it runs it on every single page, like a custom style sheet. Why? Because I want to specify all my custom styles using JavaScript not CSS.

Just kidding.

But seriously, if there was something like this, I could have a script that runs on every page and sticks an attribute on the root html element with the page’s URL. Imagine:

This would result in every page getting an attribute on the root element with the current page’s href on it.

This would allow me to scope every single one of my custom style sheet selectors to a specific domain:

Honestly, that sounds cool but impractical (not to mention the incredible security implications). It’s fun to think about though.

But hey, if I felt like disabling JavaScript, I could use this theoretical custom script functionality to run the following JavaScript on ever page I visit, just to show who really is in power:

I love old-school browser functionality like this. Can you imagine a feature like custom style sheets being proposed and implemented in today’s world? I feel like this is in Safari as a holdover from a bygone era. Could it ever get the momentum to happen today? I worry Apple might take it out sometime in the future.

All that said, if you want to read more, this post has a perspective on the history of custom style sheets in Safari that you might find interesting.

Update: 2020-01-14

I received an email from John P. Rouillard who read my question about having custom user scripts and said “You mean like greasemonkey or tapermonkey?”

I realized when I wrote that paragraph that I was merely describing what browser extensions are for. What I was trying to get at is that it would be really cool if custom user scripts were a feature of the browser, i.e. adding a custom user script was as simple as adding a custom style sheet: select a .js file on disk and boom, you’re done.

That said, maybe I’ll give one of these user scripts extensions a try. I’ve heard of greasemonkey and used it back in like 2012. But I’ve never heard of tampermonkey. Looks like it’s open source and even available for Safari . Thanks John!

fredfromminneapolis

How to disable CSS styles in Safari 17?

Previously I could used Develop > Disable Styles. I found very useful for some sites. It is no longer in that menu. How can I disable styles when using Safari 17?

Mac mini, macOS 12.7

Posted on Oct 2, 2023 3:03 PM

Matt Sagacity

Posted on Feb 22, 2024 2:17 PM

Here's a screenshot of where I found the feature in Safari 17.3.1 to hopefully save other people a couple of minutes fruitlessly hunting around in the JavaScript console tab:

css exclude safari

Similar questions

  • How do I disable the theme colour in safari 15 bar? I just installed Safari 15.0 on my Mac. How do I disable the annoying feature where the bar gets a theme colour from the web site you are at the moment? I google it and found that there should be an option in Safari Preferences under Accessibility, but I don't have it (I only have two options there, "Never use font sizes smaller than" and "Press tab to highlight each item...". Thanks in advance. 278 1
  • Safari 17 loses "disable javascript"? Since Safari 17 it looks like the 'disable javascript' option has been removed from the Develop menu. Is there an easy way to disable javascript on demand like there used to be? I found it very useful when troubleshooting web development issues. 2255 8
  • Set Safari Develop back to defaults Is there an easy way to set the Develop menu back to default selections? Alternatively if everything is unselected in Experimental Features will it run better? 74 1

Loading page content

Page content loaded

Feb 22, 2024 2:17 PM in response to fredfromminneapolis

krl09

Oct 6, 2023 9:00 AM in response to fredfromminneapolis

It's moved to the JavaScript Console, as explained on this page, along with a screen shot:

https://webkit.org/blog/14445/webkit-features-in-safari-17-0/

New tab -specific setting overlay

Some previously- global settings from the Develop menu, like disabling JavaScript or changing WebRTC behavior, have moved to Web Inspector where they are now scoped to the inspected tab , allowing you to use other tabs and windows normally.

Astreet

Apr 7, 2024 4:36 PM in response to fredfromminneapolis

I have a similar issue, I updated to OS Monterey with disable styles checked, and it's stuck off in Safari 17. I'm unable to toggle styles on or off at all. Any fix for this?

Oct 6, 2023 10:55 AM in response to krl09

It took me a while to find where it now lives, but it was indeed there!

I would rather that it were still simple, but happy it is still available.

CSS Exclusions Level 1

Exclusions defines how inline content flows around elements. It extends the content wrapping ability of floats to any block-level element.

  • 4 - 125 : Not supported
  • 126 : Not supported
  • 127 - 129 : Not supported
  • 12 - 18 : Supported
  • 79 - 125 : Not supported
  • 3.1 - 17.4 : Not supported
  • 17.5 : Not supported
  • 17.6 - TP : Not supported
  • 2 - 127 : Not supported
  • 128 : Not supported
  • 129 - 131 : Not supported
  • 9 - 110 : Not supported
  • 111 : Not supported
  • 5.5 - 9 : Not supported
  • 10 : Supported
  • 11 : Supported

Chrome for Android

Safari on ios.

  • 3.2 - 17.4 : Not supported
  • 17.6 - 18.0 : Not supported

Samsung Internet

  • 4 - 24 : Not supported
  • 25 : Not supported
  • all : Not supported

Opera Mobile

  • 10 - 12.1 : Not supported
  • 80 : Not supported

UC Browser for Android

  • 15.5 : Not supported

Android Browser

  • 2.1 - 4.4.4 : Not supported

Firefox for Android

  • 127 : Not supported
  • 14.9 : Not supported

Baidu Browser

  • 13.52 : Not supported

KaiOS Browser

  • 2.5 : Not supported
  • 3 : Not supported

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home › Forums › CSS › [Solved] Remove outline onFocus with Safari?

  • This topic is empty.
  • Author Posts

' src=

By default, Safari always add a blue glowy outline when you focus an input. But I’ve seen some designs which actually removed it. Though, I can’t figure out how to make it. I’ve tried to use border: none onfocus of the input, but the outlines still appears. Does anyone knows how stop this from happening?

Thanks, Jorge Lainfiesta

' src=

outline: none;

will do the trick ;)

Ohh, I don’t know how I didn’t think about it. Thanks! :D

  • The forum ‘CSS’ is closed to new topics and replies.
  • Skip to main content
  • Skip to search
  • Skip to select language
  • Sign up for free

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

  • See full compatibility
  • Report feedback

The @property CSS at-rule is part of the CSS Houdini umbrella of APIs. It allows developers to explicitly define their CSS custom properties , allowing for property type checking and constraining, setting default values, and defining whether a custom property can inherit values or not.

The @property rule represents a custom property registration directly in a stylesheet without having to run any JS. Valid @property rules result in a registered custom property, as if registerProperty() had been called with equivalent parameters.

Descriptors

Describes the allowable syntax for the property. May be a <length> , <number> , <percentage> , <length-percentage> , <color> , <image> , <url> , <integer> , <angle> , <time> , <resolution> , <transform-function> , or <custom-ident> , or a list of data type and keyword values.

The + (space-separated) and # (comma-separated) multipliers indicate that a list of values is expected, for example <color># means a comma-separated list of <color> values is the expected syntax.

Vertical lines ( | ) can create "or" conditions for the expected syntax, for example <length> | auto accepts a <length> or auto , and <color># | <integer># expects a comma-separated list of <color> values or a comma-separated list of <integer> values.

Controls whether the custom property registration specified by @property inherits by default.

Sets the initial value for the property.

The @property rule must include both the syntax and inherits descriptors; if either are missing, the entire @property rule is invalid and ignored. The initial-value descriptor is also required, unless the syntax is the * universal syntax definition (e.g., syntax: "*" ). If the initial-value descriptor is required and omitted, the entire @property rule is invalid and ignored.

Unknown descriptors are invalid and ignored, but do not invalidate the @property rule.

Formal syntax

In this example, we define two custom properties, --item-size and --item-color , that we'll use to define the size (width and height) and background color of the three following items.

The following code uses the CSS @property at-rule to define a custom property named --item-size . The property sets the initial value to 40% , limiting valid values to <percentage> values only. This means, when used as the value for an item's size, its size will always be relative to its parent's size. The property is inheritable.

We define a second custom property, --item-color , using JavaScript instead of CSS. The JavaScript registerProperty() method is equivalent to @property at-rule. The property is defined to have an initial value of aqua , to accept only <color> values, and is not inherited.

We use the two custom properties to style the items:

The two custom properties, --item-size: 20% and --item-color: orange; are set on the container parent, overriding the 40% and aqua default values set when these custom properties were defined. The size is set to be inheritable; the color is not.

For item one, none of these custom properties have been set. The --item-size is inheritable, so the value 20% set on its parent container is used. On the other hand, the property --item-color is not inheritable, so the value orange set on the parent is not considered. Instead the default initial value aqua is used.

For item two, CSS global keywords are set for both custom properties which are valid values for all value types and therefore valid no matter the syntax descriptor value. The --item-size is set to initial and uses the initial-value: 40%; set in the @property declaration. The initial value means the initialValue value for the property is used. The --item-color is set to inherit , explicitly inheriting the orange value from its parent even though the custom property is set to otherwise not be inherited. This is why item two is orange.

For item three, the --item-size value gets set to 1000px . While 1000px is a <length> value, the @property declaration requires the value be a <percentage> , so the declaration is not valid and is ignored, meaning the inheritable 20% set on the parent is used. The xyz value is also invalid. As registerProperty() set --item-color to not be inherited, the default initial value of aqua is used and not the parent's orange value.

Specifications

Browser compatibility.

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

  • CSS Properties and Values API
  • CSS Painting API
  • CSS Typed Object Model
  • Houdini APIs
  • Using CSS custom properties (variables) guide
  • CSS custom properties for cascading variables module

IMAGES

  1. CSS : How to target CSS for iPad but exclude Safari 4 desktop using a

    css exclude safari

  2. How to Fix CSS When It’s Not Working in Safari Browser

    css exclude safari

  3. How to Fix CSS When It’s Not Working in Safari Browser

    css exclude safari

  4. CSS Works Everywhere Except In Safari

    css exclude safari

  5. How to View Webpage Source CSS and HTML in Safari Mac?

    css exclude safari

  6. CSS color ignored by Safari

    css exclude safari

VIDEO

  1. SHAHAWA NA YAI VINAPOKUTANA 🛑URUTUBISHAJI🛑

  2. ¿Dónde hacer los mejores safaris?

  3. 4K African Animals: Chobe National Park

  4. Safari Ride in Central Pennsylvania

  5. Using the Safari 4 Web Inspector

  6. Cover Flow 3D CSS Visual Effect with iPhone Safari

COMMENTS

  1. css

    The coming versions of Firefox and Microsoft Edge have added support for multiple -webkit- CSS codes in their programming, and both Edge and Safari 9 have added support for @supports feature detection. Chrome and Firefox included @supports previously. /* Chrome 28+, Now Also Safari 9+, Firefox, and Microsoft Edge */.

  2. How to target CSS for iPad but exclude Safari 4 desktop using a media

    I want to exclude iPhone/iPod and desktop browsers. I would like to to also exclude other mobile devices if possible. I have used. <style type="text/css" media="only screen and (min-device-width: 768px) and (max-device-width: 1024px)">. but just found out that desktop Safari 4 reads it. I have tried variations with "481px" instead of "768px ...

  3. CSS @ supports rules to target only Firefox / Safari / Chromium

    As Chromium (Blink) currently is the only browser that supports @property, we need to create a @supports rule that targets Chromium only. While at it let's also create @supports rules to target only Safari (WebKit), Firefox (Gecko), or a combination thereof. Looking at what each browser uniquely supports, these three rules can be used as a ...

  4. CSS for targeting all browsers except Safari? : r/css

    CSS for targeting all browsers except Safari? I was using this before: @media screen and (-webkit-min-device-pixel-ratio:0) and (min-resolution:.001dpcm) {. But it doesn't seem to be working anymore, at least on the latest version of Safari (don't have older version anymore to test). I can't remember where I found it.

  5. Target iPhone and iPad with CSS3 Media Queries

    Well, we first exclude IE by wrapping the links in a simple conditional comment. Then we're using some CSS 3 media queries to target each device specifically. Safari on the iPhone responds to a max-device-width of 480px, and Safari on the iPad seems to respond best when both min-device-width and max-device-width are used in the query.

  6. How do I hide elements from Safari (or any browser)?

    If you need it site-wide, then you can apply it via your project's Custom Code tab on the Dashboard. Hope that helps. Cheers, Logan. I'm using a page load animation on my site. It works great on Chrome but lags and doesn't disappear on Safari. I'm looking to hide the element entirely from Safari.

  7. backdrop-filter

    backdrop-filter. The backdrop-filter CSS property lets you apply graphical effects such as blurring or color shifting to the area behind an element. Because it applies to everything behind the element, to see the effect the element or its background needs to be transparent or partially transparent.

  8. FabioRosado

    After testing different things and playing around with the media query, I've come to the final solution. I've also added a rule to trigger the CSS only when the screen is smaller than 900px high, because we don't want the menu to be broken on a larger screen. css. Copy. 1@medianot all and(max-height:899px)and(min-resolution:.1dpi){.

  9. CSS :not Selector

    W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

  10. Css hack exclusive for safari

    You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. You can also link to another Pen here (use the .css URL Extension) and we'll pull the CSS from that Pen and include it.

  11. :not

    Get started with $200 in free credit! The :not() property in CSS is a negation pseudo class and accepts a simple selector or a selector list as an argument. It matches an element that is not represented by the argument. The passed argument may not contain additional selectors or any pseudo-element selectors.

  12. safari

    font-size: 50px; } On MacOS, Safari honored the margin but ignored font-family and font-size. I tried it in Firefox, and the font-family and margin were honored. Changed "50" to "150" in both places, and in both browsers opened the CSS file itself (i.e., made the browser display the actual contents) and clicked refresh. Saw the contents change.

  13. CSS for iPad but exclude Safari 4 desktop using a media query?

    CSS for iPad but exclude Safari 4 desktop using a media query? Raw. cssForIpad.css This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters ...

  14. scrollbar-width

    Values. Defines the width of the scrollbar as a keyword. It must be one of the following values: The default scrollbar width for the platform. A thin scrollbar width variant on platforms that provide that option, or a thinner scrollbar than the default platform scrollbar width. No scrollbar shown, however the element will still be scrollable.

  15. Custom Style Sheets in Safari

    First off, Safari lets you specify a custom style sheet. In case you don't know, a custom style sheet is a bunch of CSS rules that you get to specify and then the browser will apply them to every single web page you visit. The first thing I needed to do was open twitter.com and find out what type of CSS rule I could write to target that right ...

  16. How to disable CSS styles in Safari 17?

    How to disable CSS styles in Safari 17? Previously I could used Develop > Disable Styles. I found very useful for some sites. It is no longer in that menu. How can I disable styles when using Safari 17? Mac mini, macOS 12.7. Posted on Oct 2, 2023 3:03 PM. ( 1) Best reply.

  17. CSS Exclusions Level 1

    Exclusions defines how inline content flows around elements. It extends the content wrapping ability of floats to any block-level element. Usage % of. Global. 0.57%. unprefixed: 0%. Current aligned. Usage relative.

  18. [Solved] Remove Outline OnFocus With Safari?

    This topic is empty. By default, Safari always add a blue glowy outline when you focus an input. But I've seen some designs which actually removed it. Though, I can't figure out how to make it. I've tried to use border: none onfocus of the input, but the outlines still appears.

  19. How to disable a part of css property in safari?

    Jun 10, 2022 at 8:22. As shown in the discussion in the link provided by @Cédric any method is likely to be inaccurate in the future as implementations of CSS converge. Already it is impossible to distinguish on IOS as browsers use the same underlying code. You might as well ask the user what they are running. - A Haworth.

  20. How to Fix CSS Issues on Safari

    Displaying properties in Safari. There is a CSS appearance property used to display an element using a platform-native styling based on the users' operating system's theme. To make it work on Safari, we must set the appearance property to its "none" value. Also, use -WebKit- and -Moz- vendor prefixes. Let's see an example, where we use this ...

  21. Ensuring Timely Trials : Office of the New York City Comptroller Brad

    Lengthy court case processing times have grown worse in recent years and are contributing to DOC's increased jail population. Aligning with national standards would save up to $877 million annually and help NYC achieve its commitment to close Rikers Island. Executive Summary Criminal cases in New York City take significantly...

  22. How to exclude particular class name in CSS selector?

    Method 1. The problem with your code is that you are selecting the .remode_hover that is a descendant of .remode_selected. So the first part of getting your code to work correctly is by removing that space. .reMode_selected.reMode_hover:hover. Then, in order to get the style to not work, you have to override the style set by the :hover.

  23. @property

    The @property CSS at-rule is part of the CSS Houdini umbrella of APIs. It allows developers to explicitly define their CSS custom properties, allowing for property type checking and constraining, setting default values, and defining whether a custom property can inherit values or not.. The @property rule represents a custom property registration directly in a stylesheet without having to run ...