HTML and CSS Reference
In-Depth Information
Don't worry if CSS and rules of precedence seem a bit overwhelming at this point. CSS
definitely becomes easier with practice. You'll get a chance to practice with the “cas-
cade” as you complete the next Hands-On Practice.
You will experiment with the “cascade” in this Hands-On Practice as you work with a
Web page that uses external, embedded, and inline styles. Begin by creating an external
style sheet called site.css that sets the background-color of the Web page to a shade of
yellow ( #FFFFCC ) and the text color to black ( #000000 ). The code follows:
body { background-color: #FFFFCC;
color: #000000;
Next, create a Web page called mypage1.html that is associated with the file site.css
and has an embedded style that sets the text color to blue. The file mypage1.html will
contain two paragraphs of text. The XHTML used to code the first paragraph will not
use any styles. The XHTML used to code the second paragraph will use inline styles to
set the text color to red. The code for mypage1.html follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" lang="en" xml:lang="en">
<title>External Styles</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="site.css" type="text/css" />
<style type="text/css">
body { color: #0000FF;
<p>This paragraph applies the external and embedded styles &mdash;
note how the blue text color that is configured in the embedded
styles takes precedence over the black text color configured in the
external stylesheet.</p>
<p style="color:#FF0000" >Inline styles configure this paragraph to
have red text and take precedence over the embedded and external
Search WWH ::

Custom Search