Page 109 - HTML5
P. 109

External CSS Stylesheet


         <link rel="stylesheet" href="path/to.css" type="text/css">


        The standard practice is to place CSS <link> tags inside the <head> tag at the top of your HTML.
        This way the CSS will be loaded first and will apply to your page as it is loading, rather than
        showing unstyled HTML until the CSS is loaded. The typeattribute is not necessary in HTML5,
        because HTML5 usually supports CSS.


          <link rel="stylesheet" href="path/to.css" type="text/css">


        and


          <link rel="stylesheet" href="path/to.css">


        ... do the same thing in HTML5.


        Another, though less common practice, is to use an @import statement inside direct CSS. Like this:


         <style type="text/css">
             @import("path/to.css")
         </style>

         <style>
             @import("path/to.css")
         </style>


        JavaScript



        Synchronous




         <script src="path/to.js"></script>


        Standard practice is to place JavaScript <script> tags just before the closing </body> tag. Loading
        your scripts last allows your site's visuals to show up more quickly and discourages your
        JavaScript from trying to interact with elements that haven't loaded yet.



        Asynchronous




         <script src="path/to.js" async></script>


        Another alternative, when the Javascript code being loaded is not necessary for page initialization,
        it can be loaded asynchronously, speeding up the page load. Using async the browser will load the
        contents of the script in parallel and, once it is fully downloaded, will interrupt the HTML parsing in
        order to parse the Javascript file.


        https://riptutorial.com/                                                                               93
   104   105   106   107   108   109   110   111   112   113   114