Css
Css
What is HTML?
HTML is the language for describing the structure of Web pages.
1. Try it yourself
2. https://www.w3schools.com/css/tryit.asp?filename=trycss_color
Why CSS?
The biggest problem in traditional classic (specially static) HTML
pages is that the text of your web page and the formatting
operations performed over it are all mixed inside one place / one
file.
The above image shows the use of one selector and two
Declarations. Note the use of { } : ; which are essential.
Defining a Style
A simple style rule syntax with one selector and one declaration
(property: value; pair}
selector {property: value;}
Example of defining
p {font-size: 10pt}
CSS SELECTORS
Applying Style Sheets
There are 3 types of style sheets. The difference is where the
style is defined and the area where that style is applied.
1. Inline style sheet within a tag. Applies only to that particular
occurrence of that tag.
Inline styles
Embedded styles/Internal style
External styles
Inline style sheet
Use for
Inline style sheet are should only be used where a particular
style is not going to be repeated elsewhere on the page/site
Where to define
The definition is defined within the HTML tag in the body
section of the HTML code. It must be redefined every time it is
required
Syntax
<element STYLE="property:value">
Internal style sheet
Use for
It is ideal if only 1 page is going to be used for this style.
The styles can then be used more than once throughout the page.
Where to define
The Internal style sheet is defined within the head section.
<head>
< style type="text/css">
Your Style definitions go here
< /style>
< /head>
Example:
<head>
< style type="text/css">
Body {background-color: #3333FF; color: #000033;}
p {margin-left: 6px}
< /style>
< /head>
External style sheet
Use for
This is the best method if you wish to control the design of more
that one page.
Where to define
The style definitions are only written once and saved into a file.
Each page that wishes to use that file places a link to the file in
the HEAD section.
<head> Section of your pages
Defining External style sheet