style
element and a list of CSS rule sets.style
element requires both start and end tags <style>...</style>
which are inserted between the <head>...</head>
tags (a.k.a., document head) of your web page. The type
attribute defines the type of style sheet being used so we'll put text/css
as the value. The entire contents of the style
element should be wrapped in HTML comment tags to hide it from browsers not compatible with CSS. style
element properly inserted in the document head:<html>
<head>
<title></title>
<style type="text/css">
<!--
...CSS rule sets go here...
-->
</style>
</head>
<body>
...web page content...
</body>
</html>
SELECTOR {property: value; property: value; property: value;}
SELECTOR
refers to the targetted HTML element(s). You can simply insert the actual name of the HTML element you wish to target (known as a type selector) or you can be more specific by using class or id selectors.property
refers to a CSS property.value
refers to an associated CSS value.{ }
<html>
<head>
<title></title>
<style type="text/css">
<!--
p {color: green;}
-->
</style>
</head>
<body>
<p>...This text will be green...</p>
<p>...This text will be green...</p>
<p>...This text will be green...</p>
</body>
</html>
style
element. When listing multiple CSS property/value pairs, many web authors (myself included) prefer to stack them one on top of the other and then indent the list to make it easier to read. This is perfectly fine since CSS code —like HTML— is designed to ignore extraneous white space. <style type="text/css">
<!--
H1 {
font-family: 'Times New Roman';
font-size: 36px;
background: #ffffff;
color: maroon;
}
H2 {
font-family: arial,verdana,sans-serif;
font-size: 20px;
background: #ffffff;
color: black;
}
P {
font-family: arial,verdana,sans-serif;
font-size: 16px;
background: #ffffff;
color: navy;
}
-->
</style>
<style type="text/css">
<!--
H1 {font-family: 'Times New Roman'; font-size: 36px; background: #ffffff; color: maroon;}
H2 {font-family: arial,verdana,sans-serif; font-size: 20px; background: #ffffff; color: black;}
P {font-family: arial,verdana,sans-serif; font-size: 16px; background: #ffffff; color: navy;}
-->
</style>
style
element, it will apply the associated CSS properties to all H1
, H2
and P
elements on the web page. (Need to be more 'selective' with your selectors? Try using classes and IDs.)Times New Roman
value must be enclosed in single (or double) quotation marks.font-family
property declared for the H2
and the P
elements is a comma-separated list of fonts which will be applied in order from left to right according to the availability of the font on the user's computer. (This uses the same principle for applying a list of fonts using the font
element in HTML. See Font Face for more information)..css
file. This is accomplished using external style sheets...
Free Text Editors
Free Graphics Editors
Website Analysis Tools
Free Website Templates
See also:
Best Free Web Hosting
How to Make a Web Page
If you need a .COM web address, you can get one quick and easy at...
<~ BACK | TOP | NEXT ~> |