Cascading Style Sheet Using Marquee-J List-J Table and Links
Cascading Style Sheet Using Marquee-J List-J Table and Links
• Local
– confined to a single element (tag)
• Internal
– affect elements in an entire page
• External
– can affect multiple pages
• Precedence
– Local > Internal > External
Attaching a Style Sheet
Attach a style sheet to a page by adding the code to the <head>
section of the HTML page. There are 3 ways to attach CSS to a page:
• Practice
1. add “text-align” property to make it centered
2. add “border” property to let it has black, 1px thick, solid border
at left, right, top, and bottom
• Tip: use “border: <top> <right> <bottom> <left>;” format
for 4 sides; use “border-<side>: xx yy zz;” for a particular
side, where <side> can be left, right, top or bottom. Can
apply to other similar properties.
Inline Style Sheet(contd.)
<html>
<body>
<pre>
<h1> Inline Style Sheet</h1>
<p style="font-size: 12px; color: red">
This is line one
This is line two
This is line three
</p>
</body>
</html>
8
Internet programming by Mercy
Example:
<!doctype html>
<head></head>
<body>
</body>
</html>
EXERCISE NO5: CREATING A WEB PAGE USING A TABLE
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="160" valign="top"><p><strong>Nom</strong></p></td>
<td width="147" valign="top"><p><strong>Date</strong></p></td>
<td width="200" valign="top"><p><strong>Microprocesseur</strong></p></td>
<td width="190" valign="top"><p><strong>RAM</strong></p></td>
</tr>
<tr>
<td width="160" valign="top"><p> Pentium I</p></td>
<td width="147" valign="top"><p>1993-1996</p></td>
<td width="200" valign="top"><p>60 or 90 upto 120 mégahertz</p></td>
<td width="190" valign="top"><p>8 MB, 16 MB or 32MB</p></td> </tr> <tr>
<td width="160" valign="top"><p>Pentium II</p></td>
<td width="147" valign="top"><p>1997-1999</p></td>
<td width="200" valign="top"><p>233 or 333 mégahertz</p></td>
<td width="190" valign="top"><p>16 MB, 32 MB or 64MB</p></td></tr> <tr>
<td width="160" valign="top"><p>Pentium III</p></td>
<td width="147" valign="top"><p>1999-2002</p></td>
<td width="200" valign="top"><p>450 up to 900 mégahertz</p></td>
<td width="190" valign="top"><p>32 MB, 64 MB or 128MB</p></td></tr><tr>
<td width="160" valign="top"><p>Pentium IV</p></td>
<td width="147" valign="top"><p>1999-2006</p></td>
<td width="200" valign="top"><p>1,5 Gigahertz</p></td>
<td width="190" valign="top"><p>64 MB, 128 MB or 256MB</p></td></tr><tr>
</table>
</body>
Style Sheet(Internal/External)
• A style sheet consists of a set of rules.
• Each rule consists of one or more selectors
and a declaration block.
• A declaration block consists of a list of
declarations in curly braces ({}).
• Each declaration consists of a property, a
colon (:), a value, then a semi-colon (;).
selector {property: value;}
Parts of a Cascading Style Sheet
• CSS syntax is made up of three parts:
• How to create?
– Put <style> </style> tag between <head> and
</head> tags of your HTML page
– Use type attribute to indicate the style sheet type,
usually type=“text/css”
– Put your set of style sheet rules in between
<style> and </style> tags
Style Sheet Syntax Explained
selector
property value rule
Syntax of Style sheet
15
Internet programming by Mercy
Example of an internal Style sheet cont’d
<html>
<head>
<style type="text/css">
p {font-family:"sans-serif"; color:
green}
hr {color: red}
body {color:blue; background-
color:pink}
</style>
</head>
<body>
<p>This is paragraph one</p>
<hr>
<p> This is paragraph two</p>
<hr>
This line is not within paragraph tag
</body>
16
</html> Internet programming by Mercy
<html>
<head>
<title>Internal style</title>
<style>
body { background-color: #d0e4fe; }
h1 { color: orange;
text-align: center;
}
p { color:red;
font-family: arial;
font-size: 20px;
}
</style>
</head>
<body>
h1 {color: yellow;}
h2 {color: yellow;}
h3 {color: yellow;}
h1 { color: orange;
text-align: center;
border:3px solid;
border-bottom-left-radius:2em;
}
p { color:red;
font-family: arial;
font-size: 20px;
}
</style>
</head>
<body>
h1 { color: orange;
text-align: center;
border:3px solid;
border-bottom-left-radius:2em;
}
p { color:red;
font-family: arial;
font-size: 20px;
text-indent:3em;
}
</style>
</head>
<body>
<h1>My First internal CSS example</h1>
<p>This is a paragraph 1.</p>
<p>This is a paragraph 2.</p
</body></html>
Text color CSS fonts
• Color:#036;
• Color:Red;
Font face
• font-family: "Times New Roman";
• font-family: serif;
Text-Decoration
• text-decoration:underline
• font-style: italic; • text-decoration:none;
• font-style: normal; • text-decoration:overline;
• text-decoration:line-through;
• font-size: 14px; Text-Transformation
• font-size: 100%; • text-transformation:uppercase;
• text-transformation:lowercase;
• font-weight: bold; • text-transformation:capitalize;
• font-weight: normal;
CSS Text
Text Alignment
• The text-align property is used to set the horizontal alignment of a text.
• A text can be left or right aligned, centered, or justified.
text-align: center;
text-align: left;
text-align: right;
text-align: justify;
Line Height
• The line-height property is used to specify the space between lines:
line-height: 1.8;
CSS Background, Image and Color Styles
div id=“box”
padding: 10px 10px 10px 10px;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 10px;
padding-top: 10px;
CSS Margin Properties
• The CSS margin properties are used to
generate space around elements.
• The margin properties set the size of the white
space OUTSIDE the border.
margin
padding
width
height
border
Margin (top, right, bottom, left)
You can use margin for all around the element or specify each side of the
rectangle separately.
The code could be any of the following:
CSS Code:
#mainHeading {color: green}
.name {color: red}
CSS Background, Image and Color Styles
Now create the reference links, placing the pound symbol followed by
the name of the anchor in the href of the new link.
Anchor Code:
<a href="#top">Go to the Top</a>
<a href="#text">Learn about Text Links</a>
<a href="#email">Learn about Email Links</a>
Local Links:
Go to the Top
Learn about Text Links
Learn about Email Links
Local link
Example: link1.html
<html>
Example: link2.html
<head> <html>
<title>HTML local links </title> <head>
</head> <title>HTML local links
<body> </title>
<h1 >Local Link</h1> </head>
<p>Links to other pages within your
domain</p>
<body>
<p>Click <h1 >Welcome</h1>
<a href=“link2.html” > here </a> <p>page was linked from
to go next page link 1
</p> </p>
</body> </body>
</html>
</html>
Default attributes
55
Styling Links
The links property defines how inactive, hovered,
active, and visited link states appear to the user.
Style Description
list-style-type:disc The list items will be marked
with bullets (default)
list-style-type:circle The list items will be marked
with circles
list-style-type:square The list items will be marked
with squares
list-style-type:none The list items will not be marked
Ordered HTML Lists
• An ordered list starts with the <ol> tag. Each
list item starts with the <li> tag.
• The list items will be marked with numbers
<!DOCTYPE html>
<html>
<body>
<h2>Ordered List</h2>
<ol>
<li>Banana</li>
<li>Mango</li>
<li>Orange</li>
</ol>
</body>
</html>
Ordered List
1. Banana
2. Mango
3. Orange
CSS Syntax
list-style-type: value;
➢ list-style-type: lower-alpha; (a, b, c, d, e, etc.)
➢ list-style-type: lower-latin;
➢ list-style-type: lower-roman; (i, ii, iii, iv, v, etc.)
➢ list-style-type: upper-alpha;
➢ list-style-type: upper-roman;
➢ list-style-type: decimal-leading-zero; (01, 02, 03, etc.)
➢ list-style-type: hebrew;
➢ list-style-type: lower-greek;
➢ list-style-type: none;
HTML – MARQUEES
• An HTML marquee is a scrolling piece of text
displayed either horizontally across or vertically
down your webpage depending on the settings.
This is created by using HTML <marquee> tag.
• Note: The HTML <marquee> tag may not be
supported by various browsers so it is not
recommended to rely on this tag, instead you can
use JavaScript and CSS to create such effects.
• A simple syntax to use HTML <marquee> tag is as
follows: