Unit-2 CSS Notes
Unit-2 CSS Notes
5.1.1.3 Accessibility. Sites that use CSS with either XHTML or HTML
are easier to draw so that they appear extremely similar in
different browsers
Where,
H1 is the selector, color : blue is the declaration color is the property and blue
is the value.
There are four ways of incorporating style sheets in HTML document, which
are:
Incline style declaration is the most basic style rule, which can be applied to
individual elements in the web page, Inline styles are implemented by using
style attributes with the HTML tags.
The syntax is :
e.g.
<HTML>
<BODY>
</BODY>
</HTML>
Style Sheets
The color property sets the color of the first H1 element to limegreen color and
the second one remains the default since no style attribute is applied.
<HTML>
<HEAD>
<STYLE>
Style Rules
</STYLE>
</HEAD>
</HTML>
<BODY>
…………
…………
…………
</BODY>
</HTML>
Example,
<HTML>
Style Sheets
<HEAD>
<STYLE>
H1 { Color : limegreen }
</STYLE>
</HEAD>
<BODY>
………
</BODY>
</HTML>
<HTML>
<HEAD>
<STYLE>
</STYLE>
</HEAD>
Style Sheets
<BODY>
</BODY>
</HTML>
5.1.7 Selectors
H1 { Color : blue }
<HEAD>
<STYLE>
</STYLE>
</HEAD>
<BODY>
<P> these selectors use the names of HTML elements. The only
difference is that the brackets are removed. </P>
</BODY></HTML>
<STYLE>
Class selector
</STYLE>
<BODY>
Class attribute
</BODY>
The class selector is preceded with a dot (.) called the flag
character
Example:
<HTML>
<HEAD>
<STYLE>
</STYLE>
</HEAD>
<BODY>
</H1>
</BODY>
</HTML>
Style Sheets
(c) ID Selector
<STYLE>
ID Selector name
</STYLE>
<BODY>
<P ID = “IDSelectorName”>
ID Attribute
</BODY>
Example:
<HTML>
<HEAD>
</HEAD>
<BODY>
<STYLE>
</STYLE>
Style Sheets
<H2 Id = “Control”> Fire is this color </H2>
<BR>
<BR>
<BR>
</BODY>
</HTML>
H1 { color : red }
I { color : red }
But in the above code, all type italicized tags turn to red. This is
because of the line 2 of the code.
Example:
<HTML>
<HEAD>
<STYLE>
body {
Color : Magenta;
Background : white;
ul {
color : aqua
</STYLE>
</HEAD>
</HTML>
For constructing a CSS, first style rules must be written in a document and
saves in a separate file with extension of CSS. The syntax for linking to an
external style sheet is:
<HTML>
<HEAD>
<LINK REL = “STYLESHEET“ HREF = “Dictionary path where the style sheet is
saved”>
</HEAD>
<BODY>
………
………
</BODY>
</HTML>
For example, consider a style sheet definition which specifies two styles:
a global style applies to all <H2> element (green, arial font family,
normal size)
Style Sheets
a generic style class named warning (red, bold, italic) which will apply to
any element which uses that class.
<STYLE>
H2 { COLOR : limegreen }
</STYLE>
HTML file:
<HTML>
<HEAD>
</HEAD>
<BR>
<P class = “warning”> Changing the rules may not be such fun
Importing a style sheet, automatically pulls, the style rules into the document
for use. Once imported, changes made to the style sheet will not be reflected
in the web page into which it has been imported. This problem can be avoided
by linking the style sheet to the main document rather than importing it.
<HTML>
<HEAD>
</STYLE>
</HEAD>
<BODY>
………
………
</BODY></HTML>
(c) font-style – Denotes the style of the text for example normal,
bold, italic etc.
(a) Color – Denotes the color property, used to set text color.
Style Sheets
(b) Background-color – This property sets an element’s background
color.