Lesson 12: CSS External
External CSS
- Internal CSS is very useful but it also has limitations. For example, if you were building a website with multiple pages, internal CSS would become very messy and would lead to code duplication.
- External CSS is where an external style sheet is created.
- The stylesheet has a similar layout to the internal CSS but there is no need to define a style tag in the style sheet.
Example of a style sheet(click style.css):
- You can then reference the style sheet in the appropriate web pages.
- The stylesheet is referenced in the head section of the HTML sheet.
- The link rel tag is used to reference the style sheet.
Example:
Advantages of External CSS
- You can use the same CSS file for multiple HTML files which reduces duplication of code.
- Since CSS code is in a separate document, the HTML files have a cleaner structure and are smaller in size.