Mac Safari Css Hack Only

If you know CSS, you know that the above just seems to good to be true. Well, it is!

You really can’t make this happen without a little JavaScript. But, with a little JS, we can make our CSS much more complete.

Disable Site-specific Hacks—Use this to disable the modifications to Safari and test your site for correct operation (if Apple engineers have modified Safari specifically to work around a problem with your website). Disable Local File Restrictions—Disable security checks that may prohibit local development.

CssMac Safari Css Hack Only
  • Sep 17, 2018  Visiting the webpage on a Mac will cause Mail and Safari to freeze for a second, and the computer running them to slow down. But caused an iOS 11.4.1 device to only.
  • . Updated for Microsoft Edge and Safari 11. This is my public LIVE browser test page for my own CSS hack contributions to the universe. If you are new to web development. These are quick-fixes for browser-specific bugs, not anything to do with illegal activity. If you use them, remember that CSS Hacks are bandaids, temporary fixes ONLY!

Let’s imagine that we wanted to apply a whole bunch of CSS rules to Mac OS X browsers only. Wouldn’t it be great if we could just do something like:

Ideally, this would force all Mac OS X browsers to style paragraph tags with a 2em line height.

Well, as I said before, with a little JavaScript, we can actually make this possible. The below example uses jQuery.

Essentially, we’re adding the mac-os class name to your body tag if a Mac OS operating system is detected, which makes the above CSS rules possible!

Quick Tips

  1. You may not have the jQuery library loaded, in which case, this is easily done with “traditional” JavaScript:document.getElementsByTagName('body')[0].className += ' mac-os';
  2. If you wish to target only Webkit browsers on the Mac (Safari and Chrome), you can couple this tip with webkit’s proprietary media query as follows:
  3. Similarly, if you wanted specific styles to target individual Mac browsers, you could do the following:

    Then, within your CSS, you’re able to do something like the following:

  4. Although these tricks may do the job, they may cause issues for you down the line. It may make sense to “reset” your CSS styles first. Each browser has a different set of defaults styles for each element (some might have a line height of 1em for paragraph tags while others have 1.25 em as the height).The best way to ensure consistency is to first set a base style for all elements. This technique is popular within WordPress themes but can be done easily by adding this one line of CSS to the beginning of your stylesheet:
    Minified CSS reset styles
(Redirected from Css expressions)

A CSS hack is a coding technique used to hide or show CSSmarkup depending on the browser, version number, or capabilities. Browsers have different interpretations of CSS behavior and different levels of support for the W3Cstandards. CSS hacks are sometimes used to achieve consistent layout appearance in multiple browsers that do not have compatible rendering. Most of these hacks do not work in modern versions of the browsers, and other techniques, such as feature support detection, have become more prevalent.

Types of hacks[edit]

Invalid or non-compliant CSS[edit]

Due to quirks in the interpretation of CSS by various browsers, most CSS hacks involve writing invalid CSS rules that are interpreted only by specific browsers, or relying on bugs in specific browsers. An example of this is prefixing rules with an underscore (as in _width) to target Internet Explorer 6—other browsers will ignore the line, allowing it to be used to write code specific to one browser.

Css Target Safari

Conditional comments[edit]

Prior to version 10, Internet Explorer supported a special comment syntax that would allow blocks of HTML to be read only by specific versions of the browser. These comments are mostly used to provide specific CSS and JavaScript workarounds to older versions of the browser. No other browsers interpreted these comments or offered similar functionality.

The following are examples of the different syntax for these comments.

Criticism[edit]

Hiding code using hacks often leads to pages being incorrectly displayed when browsers are updated. These hacks can lead to unexpected behavior in newer browsers that may interpret them differently than their predecessors. Since Internet Explorer 6 and 7 have fallen out of use, CSS hacks have declined as well. Modern methods of feature targeting are less fragile and error-prone.

Alternatives[edit]

Browser prefixes[edit]

Each of the most popular browser rendering engines has its own vendor-specific prefix for experimental properties. However, due to the proliferation of these properties in live code, the browser vendors have begun to move away from this in favor of user-controlled feature flags.[1]

List of prefixes[edit]

The following is a list of prefixes from various layout engines:

Vendor PrefixIn UseLayout EngineCreated byUsed by
-ah-yesFormatterAntenna HouseAntenna House Formatter
-apple-yesWebKitApple Inc.Apple Safari 2.0, Opera Widgets, WebKit-Based Browsers (as legacy prefix)
-atsc-Advanced Television Systems Committee standards
-epub-yesWebKitEPUB Working GroupChromium / Google Chrome, WebKit-Based Browsers
-fx-yesSun Microsystems (now acquired by Oracle Corporation)JavaFX applications
-hp-Hewlett-Packard (now HP Inc. and Hewlett Packard Enterprise)
-khtml-yes / yesKHTML / WebKitKDEKDE Konqueror / Apple Safari 1.1 through Safari 2.0, WebKit-Based Browsers (as a legacy prefix)
-moz-yesGeckoMozilla FoundationGecko-Based Browsers[?], Mozilla Firefox
-ms-yesTrident / MSHTMLMicrosoft CorporationMicrosoft Internet Explorer
mso-OfficeMicrosoft CorporationMicrosoft Office[?]
-o-yesPrestoOpera SoftwareOpera desktop Browser up to version 12.16, Opera Mini, and Opera Mobile up to version 12.1, Nintendo DS & Nintendo DSi Browser, Nintendo Wii Internet Channel
prince-yesPrinceYesLogicYesLogic Prince
-rim-WebKitBlackBerry LimitedRIM Blackberry Browser
-ro-yesMARTHAReal ObjectsReal Objects PDFreactor
-tc-TallComponentsTallComponents
-wap-yesPrestoThe WAP ForumOpera Desktop Browser and Opera Mobile, The WAP Forum
-webkit-yesWebKit/BlinkApple Inc. (WebKit)/Google Inc. (Blink)Apple Safari & Safari for iOS (WebKit), Chromium / Google Chrome desktop and mobile (Blink), Opera desktop and mobile from version 14 (Blink), Android browser (Blink), Nokia MeeGo Browser 8.5, Nokia Symbian Browser 7.0 and later (WebKit), Blackberry Browser 6.0 and later (WebKit).
-xv-noPrestoOpera SoftwareOpera Desktop Browser for Windows 2000/XP

Example[edit]

Limitations[edit]

Vendor prefixes were designed for features that were under development, meaning that the syntax may not even be final. Also, adding a rule for each browser's implementation of a function does not scale well when you want to support many browsers. Consequently, the major browser vendors are moving away from vendor prefixes in favor of other methods such as @supports feature queries.

Feature detection[edit]

JavaScript feature detection[edit]

Css Target Safari Only

Multiple JavaScript libraries exist to detect what features are available in a particular browser so that CSS rules can be written to target them. Libraries such as Modernizr add classes to the html element, allowing for CSS rules such as .cssgradients.header.

@supports[edit]

Css Safari Only

A new feature known as feature queries was introduced in CSS3, allowing the detection of specific functionality within the CSS (without requiring the use of a JavaScript library for feature detection). This new directive can be used to check for the support or lack of support for a specific feature, and checks can be combined with and, or, and not. Obviously, @supports rules will only work on browsers that support @supports.

JavaScript polyfills[edit]

While JavaScript feature detection and @supports rules can help to target browsers that require fallback functionality, they will not address bugs in specific browsers or enable that advanced functionality. Polyfills, scripts that make behavior consistent across all browsers, can be used to add support for new CSS rules (for example, media queries in IE 8) as well as fix bugs in specific browsers. Since polyfills add or fix functionality in browsers that do not have it, they serve a different purpose than feature queries, but can be used in combination with them.

See also[edit]

Notes[edit]

  1. ^'Vendor Prefix'. Mozilla Developer Network. Retrieved 12 October 2016.

External links[edit]

  • Browser Strangeness - Jeff Clayton's Live CSS hacks and tests to filter for mainstream browsers, including the only known CSS Hacks for Safari 7 and 8
  • browserhacks.com - Multiple browser filter methods and tests (Hugo Giraudel, Joshua Hibbert, Tim Pietrusky, Fabrice Weinberg, Jeff Clayton)
  • Safari/Webkit (webkit) prefix filters refix filters]
  • Opera (wap) prefix filters - This page has all of Opera's CSS selectors.
  • CSS Filters – A fairly complete table of CSS hacks which show and hide rules from specific browsers.
  • [ CSS Filters – CSS-only Filters Summary] – More CSS filters.
  • Filters and Cross-Over – CSS filters. Parsing errors marked red.
  • - CSS Browser Selector - Allows to combine browser specific CSS in single stylesheet (using JavaScript).
  • - #IEroot - Targeting IE with a single stylesheet containing all CSS (without using JavaScript, but using conditional comments to assign browser-specific tag to arbitrary content root [div])

Safari Specific Css

Retrieved from 'https://en.wikipedia.org/w/index.php?title=CSS_hack&oldid=967103592#cssexpressions'