Embedded Style
Description
You can use the style
element to
define an embedded style.
Example
The selector in this example is a
,
which instructs the browser to apply the style
to every a
element in the document.
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
a {<!--from w ww .jav a 2 s .co m-->
background-color:grey;
color:white
}
</style>
</head>
<body>
<a href="http://java2s.com">Visit the website</a>
<p>This is a test.</p>
<a href="http://w3c.org">Visit the W3C website</a>
</body>
</html>
Example 2
You can define multiple styles in a single style element.
The following code shows a style element that has two styles.
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
a {<!-- w ww . ja va 2s . com-->
background-color:grey;
color:white
}
span {
border: thin black solid;
padding: 10px;
}
</style>
</head>
<body>
<a href="http://java2s.com">Visit the website</a>
<p>I like <span>apples</span> and oranges.</p>
<a href="http://w3c.org">Visit the W3C website</a>
</body>
</html>