Skip to content

Instantly share code, notes, and snippets.

@electrotype
Created October 12, 2018 08:42
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save electrotype/7960ddcc44bc4aea07a35603d1c41cb0 to your computer and use it in GitHub Desktop.
Save electrotype/7960ddcc44bc4aea07a35603d1c41cb0 to your computer and use it in GitHub Desktop.

Fix for FOUC :

At the top of your HTML:

<!doctype html>
<html>
<head>
    <style>html{visibility: hidden;opacity:0;}</style>

At the end of your last .css file:

html {
    visibility: visible;
    opacity: 1;
}
@mig8447
Copy link

mig8447 commented Nov 11, 2020

This also works if you add another style tag at the end of your body with

<style>html{visibility: visible;opacity:1;}</style>

@jafrajarvy292
Copy link

This also works if you add another style tag at the end of your body with

<style>html{visibility: visible;opacity:1;}</style>

This seems to work for me and is the most convenient. I'm using a a framework for my project and so, while I can add the <style> group in my <head>, I have little control over where the html style appears in my css file. This is what I end up with and it works.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <style>
        html {
            visibility: hidden;
            opacity: 0;
        }
    </style>
    <link rel="stylesheet" href="main.css">
</head>
<body>
    [...]
    <style>
        html {
            visibility: visible;
            opacity: 1;
        }
    </style>
</body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment