Web Design/External CSS
< Web DesignIf you want to use the same CSS for several Web pages it is worth considering using a separate style sheet which you then link from each page. You can do this as follows:
<link type="text/css" rel="stylesheet" href="style.css">
The link tag should be placed within the <head> & </head> element. Here is an HTML file with a link to an external style sheet:
The link element's rel attribute must be set to the value stylesheet to allow the browser to recognize that the href attribute gives the Web address (URL) for your style sheet.
Exercise 1 - Creating a HTML page with an external CSS
In this example we will create:
- a file called externalcss.html (which is the HTML web page); and
- a file called external.css (which holds all the style information);
Both files should be located in the same directory.
externalcss.html will obtain style information from external.css
Part 1 - Creating externalcss.html
Type the code below into your code editor and save the file as externalcss.html (this page is a HTML webpage)
<html> <head> <title>My CSS Webpage</title> <link type="text/css" rel="stylesheet" href="external.css"> </head> <body> <h1>Some heading</h1> <p>This is a webpage that uses an external stylesheet. The style is controlled from the file <b>style.css</b>.</p> <p>This is an advantage because you can call this same CSS Style on many pages. When you want to edit the style for the whole website you just have to change code within the <b>external.css</b> file.</p> </body> </html>
Part 2 - Create a page called external.css
The CSS code below should make the:
- Left and right margin indent by 10%
- Text color appear as white
- Background color appear as Black
Type the code below into your code editor and save the file as external.css
/* style.css - a simple style sheet */ body { margin-left: 10%; margin-right: 10%; color: white; background: black; }
View externalcss.html in your internet browser and you will notice that the css code from external.css is formatting the webpage.
HTML: What is HTML, Advanced HTML Tutorial, HTML Challenges, Lists and Tables, The Structure of HTML, Pen and Paper HTML activities
CSS: Learning Basic HTML and CSS, CSS challenges, Embedded CSS, Basic HTML and CSS Tutorial, Inline CSS, Develop cascading style sheets, CSS3 Animations
PHP: Simple functions in PHP, Dynamic websites, PHP challenges, Dynamic websites with PHP, Generating a receipt with PHP, Responding to HTML forms with PHP,
JavaScript: An Introduction to Programming with JavaScript, JavaScript Challenges, Getting to know JavaScript events, Getting to know the Document Object Model with JavaScript, JavaScript pen-n-paper activities, Web Programming Intro, Produce basic client side script for dynamic web pages
XML: XML challenges
Databases: Creating Database Tables
Projects: A small website project, A step-by-step web design project, Build a basic web page, Build a small website
Challenges: Web design, HTML, AJAX, CSS, JavaScript, PHP, XML, Information Architecture, Algorithms
Activities: Web design group learning activities, Pen and Paper HTML activities, A Web Design Quiz show, Ordering Tasks for a Web Project, Paired Bio Pages, Scoping a Small Project, Emerging Technologies Research Activities
Project management: An introduction to Project Management, Developing a Client Project
Design: Accessibility, Design Principles for Web Design, Design Suggestions
Testing: Testing Website performance, Website Performance Test Plan
Publishing: Getting Your Site On the Web
Certification and standards: Cert IV Website Qualifications in Australia, Australian Qualifications, Web design qualifications
Professional development: Contribute to personal skill development and learning, Useful Applications, Useful Books, Emerging Technologies, Using the Internet as a Learning Tool
Course meta-information: Web Design, About the web design learning project, New Structure, Sample Timetable