CSS requirements (Cascading Design Sheets) can be published within the web page or in an exterior computer file with the "css" expansion.
CSS-based style linens contain a list of claims, or concept places. A concept set is made up of a selector followed by a announcement prevent containing style qualities and their principles.
When the CSS value is published in the HTML papers, it can be included in the HEAD area, in a <style> tag or in the HTML factor, with "style" feature.
• Design linens included within HTML element
<div style="property:value;">Content</div>
The "style" feature can contain a semicolon divided record of CSS conditions to that particular factor.
• CSS included in the HTML HEAD section
<html>
<head>
<title>Titlul</title>
<style type="text/css">
selector {
property:value;
another_property:value;
}
</style>
</head>
<body>
... Page cotent ...
</body>
</html>The kind feature describes which terminology is used in the design piece. It is necessary for HTML4 and XHTML, but it is optionally available in HTML5 (defaulting to "text/css").
Notice the CSS format. The property:value couples are included in a announcement prevent (starts with the eventually left wavy prepare and comes to an end with the right wavy brace) of a selector. Between "property" and "value" must be a intestinal tract personality (:) and each couple comes to an end with a semicolon (;)
- When the design linens are published in an exterior computer file, the CSS value is included in the same way, but without the <style> tag.
CSS Selectors
You use selectors to determine the components on a web page that you want to use certain qualities to.
There are various kinds of selectors: worldwide selector, Type selector, category selector, ID selector and feature selector.
Universal selector
The worldwide selector is showed with an asterisk (*) and is used to all components.
In the following value, every factor containing HTML textual content would be designed with Calibri or Arial font:
* { font-family: Calibri, Arial, sans-serif; }Kind selectors
The type selector chooses a component by its type, it symbolizes the factor or HTML tag to design.
The following guidelines use a typeface design to all "h1" meta labels and a shade design to all "<p>" components within a website.
h1 {
font-size: 18px;
}
p {
color: blue;
}Category selectors
The category selector suits components with the specified category name.
When you want to use the same CSS concept on different HTML meta labels, you can use a category selector.
To make a category within a HTML tag, just add a "class" feature and its value.
Example: <div class="clas1"> Articles </div>
- In CSS, the category selector is beat by a (.) personality.
The next CSS value is applicable a shade design to all HTML components with class="clas1"
.clas1 {
color: green;
}ID selectors
ID selectors appear to be category selectors except they appear once in the HTML papers.
An ID selector can appear many periods in a CSS papers, but it can appear only once in an HTML papers, interpreting only one HTML tag.
To make an ID within a HTML tag, just add an "id" feature and its value.
Example: <div id="id1"> Articles </div>
- In CSS, the ID selector is beat by a hash icon (#).
The next CSS value is applicable a font-size design to the HTML factor with id="id1"
#id1 {
font-size: 15px;
}Feature Selectors
In inclusion to id and category features, any credit can be used for choice with via credit selectors.
- In CSS, the credit selector is included between rectangle supports [], they have four major alternatives for discovering an element:
1) [attr]
Selects components with the credit attr
The example below designs all components with a headline attribute:
[title] {
color: blue;
}2) [attr=val]
Selects components with the feature attr with the value similar to val.
The example below designs all components with title="coursesweb":
[title=coursesweb] {
color: green;
}3) [attr~=val]
Selects components with the feature attr that contain the space-separated feature somewhere in the value.
In the fallowing example, whenever the phrase course seems to be in the "title" feature of an anchorman (<a>) factor, the website weblink will not have an underline.
a[title~=course] {
text-decoration: none;
}4) [attr|=val]
Selects components with the feature attr whose value implies val or starts with val followed by the separator (-) (val-word).
The example below designs all components with a lang feature that contains a lang value (en). This performs even if the feature has hyphen ( - ) divided principles (en-us, en-au, ...).
[lang|=en] { color:blue; }CSS is case insensitive. For example, large home is comparative to the COLOR home. By meeting, qualities and principles are generally published using lowercase character types.


