UNIT-02-CSS
UNIT-02-CSS
HTML tag.
• The declaration has two parts: a property and a value.
• Selectors can be placed into classes so that a tag can be
formatted in a variety of ways.
• Declarations must be separated using colons and terminated
using semicolons.
• selector {property: value; property: value ...}
• This form is used for all style declarations in stylesheets. The
declaration has three items: the property, a colon, and the value.
• If you miss the colon or fail to put the semicolon between
declarations the style cannot be processed.
The selector is used to create a link between the rule and the HTML tag.
• There are several different types of selectors in CSS.
• CSS Id Selector
• The grouping selector is used to select all the elements with the
same style definitions.
• Grouping selector is used to minimize the code. Commas are
used to separate each selector in grouping.
• Note: Suppose you want to apply common styles to different
selectors, instead of writing rules separately you can write them
in groups as shown below.
• h1 {
h1,h2,p {
• text-align: center;
text-align: center;
• color: blue;
color: blue;
• } }
• h2 {
• text-align: center;
#div-container, .paragraph-class,
• color: blue;
h1{
• } color: white;
• p{ background-color: purple;
• text-align: center; font-family: monospace;
• color: blue; }
• }
Attribute Selector
Selector:Pseudo-Class {
Property: Value;
}
• h1:hover{
• background-color: aqua;
• }
Divisions
• An element in an HTML document is either a block element or an inline
element.
• A block would be something like a paragraph, while an inline might be
something like text, a figure or an individual character that is part of a block.
• Each of these can be manipulated separately.
• a <div> . . . </div> pair of tags are wrapped around the element. Any
formatting that needs adding is placed inside the div tag thus.
• <div class="anyelement">
• <p>. . . < / p>
• <h2>. . . </h2>
• <p>…..</p>
• </div>
PROPERTIES AND VALUES IN STYLES
• Fonts:
• Fonts are identified by giving the name of a specific font. Many Microsoft
Windows and Apple systems have similar sets of TrueType fonts. Unfortunately
UNIX systems use Type 1 and PostScript fonts.
• You should try to use TrueType fonts in your Web pages but provide an option
for users who don't have these fonts. This can be done in two ways. First, you
may specify as many fonts as you like for each style in the hope that most
people will have at least one of them.
• Second, you can specify a default generic font which all browsers on all systems
can handle. Five generic fonts are specified: serif (times), sans-serif (arial),
cursive, fantasy, monospaced (courier). Font names which include whitespace
should be placed in quotes.
FORNT
• P{
• }
• font-style: normal|italic|oblique
• Fairly straightforward. Oblique fonts are slanted, italic do not have to be.
• font-weight: normal|bold)bolder|lighter|100|200|
• 300|400|500|600|700|800|900
• The weight of any font can be altered. The first four options are relative
while the numbered values give absolute weights. Not all fonts support all
possible weights and you may want to be careful using absolute weights.
• font-size: [small|medium|large]|[smaller|larger]|
• <length>|<percentage>
• As well as changing the weight you can alter the size. Again, a
choice of relative sizes is possible.
• Font lengths should be given in appropriate units such as pt.
Backgrounds and Colors
• color: <value>
• Backgrounds for the whole page or individual elements can have their
color set from the stylesheet. Elements can also have transparent
backgrounds.
• background-image: URL|none
• Instead of a color an image can be used, identified by its URL. If you set