SYNTAX: how to write and use a CSS file
Should not write the style of a page directly between TagD <head> ... head> unless the page is used once of few times into the site. It is usually better to write a CSS in a separate file and link it with the following code, inserting the connection between the <head> ..... head> of the HTML page
< link href="css/mystylesheet.css" rel="stylesheet" type="text/css" />
Let's make a new css file with our editor. At the first line we write
@charset "utf-8";
/* CSS of the page ........*/
where in the second line we put the information on which pages the the style sheet is used for, between the symbols / * ....... * / so that this text is not processed by the interpreter.
The CSS file can modify the whole HTML page or the single elements that can be inserted in a given HTML page between o TAG
<body>.... body>. Let's see some elements
a) CLASS let's take a class that we call 'giustifica' - We write this name preceded by a dot - precisely to show that it is a class and then we open a brace '{'.
After the brace we put the sequence of instructions, and finally we close the brace '}': The class can be called in a TAG, the name of a DIV or other, as we shall see below.
The instruction for this class can be written all in one row or can be more visible with many rows. this class gives the size and alignment of a text.
SYNTAX = .name {
command1: content1 ; command2: content 2; ........commandn: content n;
code |
sintax scheme |
.giustifica {
font-family: Arial;
font-size: medium;
text-align: justify;
}
|
..classname {
character family : Arial;
character size: medium;
text alignement: justifed ;
} |
b) ELEMENT identified by its name. The uppersaid class can be attributed to any element, instead this case the formatting affects only the element with that name. For example, consider an element which we call 'corpo' preceded by a pound sign, and open a brace '{'. After the brace put the sequence of instructions and close the curly brace '}'
#corpo {
margin: 0px auto;
border: 0px solid rgb(0, 0, 0);
width: 980px;
height:640px;
text-align: left;
padding: 0px;
position: relative;
}
|
#element name {
margin
border: solid black color line;
980 pixels;
640 pixels;
no padding
position: relative in respect to another container containing this one |
These are the most common features. But items can be edited with much more: you can enter rounded edges, images or background colors too nuanced, and more. For this I suggest to use a specialized editor that aids listing all possible commands that you can choose according to your needs and the tag that you work in.
Better to install DREAMWEAVER ADOBE THAT IS THE BEST AND THE MOST EASY TO USE TO ME.
NOTE 1: STYLES SET WITH CSS CAN BE CHANGED IN EACH LINE. FOR EXAMPLE
paragraph TAG <p> .......</p) you can inset the instruction <p style=" element: value; element1: value1; ........ element n : value n; ">.......</p>. OR, use a predefined class into the CSS linked to the page and write
<p class="name of class"> .......</p
The command applies to all elements that stands in place of the dots above. You can invent and try to edit the tags as you like, because most TAGs can be changed one by one in this way, as we have said for the previous one, for example:
- <span> ..... </span>
- <td> ...<td>
- <table> .... <table>
- <body>.....</body>
- <div> .... </div>
- <ul> ..... </ul>
etc etc
NOTE 2: YOU COULD ALSO WRITE A CSS FILE THAT CONTAINS ALL THE different named ELEMENTS OF ALL YOUR PAGES , AND CONNECT TO WHICH YOU DO NEED EVEN IF YOUR PAGES ARE NOT EQUAL.
PERSONALLY I DON'T LIKE THIS SOLUTION, BECAUSE CAN CREATE MORE CONFUSION WHEN YOU HAVE TO REVAMP A SITE.
|