A partly sunny mountain-scape.

Assignment 5

How to Apply CSS to HTML

It is a best practice to link to external Cascading Style Sheets (CSS) rather than styling a page directly from the HTML document. To acheive this, we create a .css file and link to it at the top of our html document.

Example:

            
                <head>
                    <link rel="stylesheet" href="styles.css"></link>
                </head>
            
        
It is also possible to use css directly within an HTML document. To do this we include the css code in inside an html tag.

Inline CSS Example

            
                <p style="color:red;" >
                    This paragraph will be red.
                </p>
            
        

How to Use JavaScript in a Webpage

To link an external javascript file, we simply create a .js file and link to it.

External Linkage Example

            
                <head>
                    <script src="script.js"></script>
                </head>
            
        
It is also possible to use javascript directly within an HTML document. To do this we include the javascript code in a <script> tag.

Internal Scripting Example

            
                <script>
                    console.log("This script runs from within the HTML document!");
                </script>