Page 127 - DCAP408_WEB_PROGRAMMING
P. 127
Unit 4: Cascading Style Sheets
</body> Notes
</html>
Benefits of External CSS
It keeps your website design and content separate.
It’s much easier to reuse your CSS code if you have it in a separate file. Instead of typing
the same CSS code on every web page you have, simply have many pages refer to a single
CSS file with the “link” tag.
You can make drastic changes to your web pages with just a few changes in a single CSS
file.
Help to achieve the consistency in the styles through out the pages.
Did u know? What is the limitation of External CSS?
If the user downloads the page and if he forgot to download the Linked CSS then he/she
will not be able to view the page with all the styles.
4.5.4 Importing Style Sheets
The @import rule thus allows you to keep some things the same while having others different.
Syntax:
@import url (nameoffile.css)
It must come at the start of the style sheet, before any rulesets (a ruleset is something like P
{color: red}). Alternatively, it can be specified as:
Syntax:
@import “nameoffile.css”
as @import url (“nameoffile.css”)
or as @import ‘nameoffile.css’
However, Internet Explorer only supports the url() formats, not the “ and ‘ formats.
Self Assessment
Fill in the blanks:
10. The simplest and most direct way of applying CSS to an element is to write it into the tag
itself as a style attribute ………………...
11. An entire style sheet can be embedded in an HTML document using the <STYLE> element
contained within the ………………... block.
12. If you set a style on every paragraph on your site, you can do it once with like 6 lines of
code and an ………………...
LOVELY PROFESSIONAL UNIVERSITY 121