Web Design/Embedded CSS

< Web Design
Web Design Embedded CSS
This page is part of the Web Design project.

Example 1

As you can see the style information is placed between the <head> & </head> tags, inside the <style> & </style> tags

The CSS code below should make the:

Type the code below into your favorite code editor and save the file as cssexample.html

<html>
<head>
<style type=text/css>
body { background-color: yellow; }
p { color: green; font-size:10px; }
h2 { color: blue; }
</style>
</head>
<body>
<h2>Internal CSS</h2>
<p>This page uses internal CSS.  Using the style tag we are able to modify
the appearance of HTML elements.</p>
</body>
</html>




Exercise 2 – Changing the font family and font style using CSS.

The CSS code below should make the:

Paste the code below into your code editor, create a new page called cssexample2.html

<html>
<head>
<style>
p { 
font-family: helvetica, impact, sans-serif;
font-style: italic;
}
h2 { 
font-family: "gill sans", "new baskerville", sans-serif; 
}
</style>
</head>
<body>
<h2>This is a Heading</h2>
<p>This is some text, which is being affected by CSS.</p>
</body>
</html>




Exercise 3 – Changing the border and aligning the text using CSS.

The CSS code below should make the:

Paste the code below into your code editor, create a new page called cssexample3.html



<html>
<head>
<style>
p { 
background: pink;
border: solid green;
text-align: center; 
}
h2 {
border: dotted red;
}
</style>
</head>
<body>
<h2>This is a Heading</h2>
<p>This is some text, which is being affected by CSS.</p>
</body>
</html>




Exercise 4 – Changing the margin padding using CSS.

The CSS code below should make the:

Paste the code below into your code editor, create a new page called cssexample4.html

<html>
<head>
<style type="text/css">
p {margin-left: 2cm}
</style>
</head>

<body>
<h2>This is a heading with no margin specified</h2>
<p>This is a paragraph with a specified left margin</p>
</body>

</html>



Exercise 5 – Changing the color of a Horizontal Rule using CSS.

The CSS code below should make the:

Paste the code below into your code editor, create a new page called cssexample5.html

<html>
<head>
<style>
hr { 
color: blue;
}
</style>
</head>
<body>
<h2>This is a Heading</h2>
<hr>
<p>This is some text, which is being affected by CSS.</p>
</body>
</html>


This article is issued from Wikiversity - version of the Sunday, July 27, 2008. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.