Results 1 to 6 of 6

Thread: Modifying a CSS file based on browser type?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Modifying a CSS file based on browser type?

    I know you can write a javascript to determine the browser type and then load a css file manually. However, I was wondering if a single CSS file could be modified based on browser type?

    Thanks,
    Blake

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Modifying a CSS file based on browser type?

    What do you mean by browser type? Typically you would use media queries to limit css by window size, or use conditional comments (https://docs.microsoft.com/en-us/pre...ctedfrom=MSDN) for IE 9 and below.

    What are you attempting to do?

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Modifying a CSS file based on browser type?

    Instead of having a CSS file each browser type and using Javascript to load the correct file, I wanted to know if you could perform the browser type check within a CSS file?
    Blake

  4. #4
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Modifying a CSS file based on browser type?

    You're trying to solve the wrong problem. You shouldn't need CSS per browser type.

    There are sometimes some oddities you'll need to account for, which is why some browsers have prefixes (https://developer.mozilla.org/en-US/.../Vendor_Prefix), but other than legacy IE browsers (which you can use the conditional comments for, or for newer IE, since IE is stupid, you can use directives that are ignored by proper browsers: https://stackoverflow.com/questions/...hack-for-ie-11), there should be no need for custom CSS.

    You can use media queries for browser size if you're dealing with mobile browsers.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Modifying a CSS file based on browser type?

    I'm just dealing with straight laptop/desktop screens at the moment. I'm simply not that great at web development, ie; javascript, css, etc. so you lost me with "directives". The whole reason I was using different CSS files based on browser was because the site didn't render correctly. There were a few elements that were off.
    Blake

  6. #6
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Modifying a CSS file based on browser type?

    Quote Originally Posted by blakemckenna View Post
    I'm just dealing with straight laptop/desktop screens at the moment. I'm simply not that great at web development, ie; javascript, css, etc. so you lost me with "directives". The whole reason I was using different CSS files based on browser was because the site didn't render correctly. There were a few elements that were off.
    Often times that is because of inherent styles for a browser. You may want to look into using a CSS reset: https://cssreset.com/what-is-a-css-r...more%20legible.

    Or, often times you can just use a library like bootstrap, which has its own resets.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width