Css 214
Css 214
Css 214
CSS
• Cascading Style Sheets, fondly referred to as CSS, is a simple design
language intended to simplify the process of making web pages
presentable.
• CSS handles the look and feel part of a web page. Using CSS, you can
control the color of the text, the style of fonts, the spacing between
paragraphs, how columns are sized and laid out, what background
images or colors are used, layout designs,variations in display for
different devices and screen sizes as well as a variety of other effects.
• CSS is easy to learn and understand but it provides powerful control
over the presentation of an HTML document. Most commonly, CSS is
combined with the markup languages HTML or XHTML.
Advantages
• CSS saves time
• Pages load faster
• Easy maintenance
• Superior styles to html
• Multiple device compatibility
• Global web standards
• Selector{property:value}
The type of selectors
• H1{
color:#36ffff;
}
• *{
color:#000000;
}
• Ul em {
color:#00000
}
The class selectors
• .black{
color:#000000;
}
• H1.black
{ color:#000000;
}
• <p class =“center bold”>
some content here
</p>
Question
In Css what does h1 can be called as
A selector B attribute
C value D tag
The id selectors
• #black
{ color:#000000;
}
H1#black
{color:#000000;
}
#black h2{
color:#000000;
}
Question
• If we want define style for an unique element, then which css
selector will we use ?
A id B text
C class D name
Question
Can we align a Block element by setting the left and right
margins ?
A yes, we can
B Not possible
Question
Which of the following attributes is used to specify elements to
bind style rules to?
A id B class
• h1 {
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}
Grouping Selectors
Example: Many selectors
h1, h2, h3 {
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}
Example: various id selectors
#content, #footer, #supplement {
position: absolute;
left: 510px;
width: 200px;
}
Question
• In css what does “color:red” can be called as
• A selector B rule
• Syntax
• <htmltag style="cssproperty1:value; cssproperty2:value;"> </htmltag>
• Example
<h2
style="color:red;marginleft:40px;">Inline CSS is applied on this headin
g.</h2>
<p>This paragraph is not affected.</p>
• Output
• Inline CSS is applied on this heading.
Disadvantages of Inline CSS
• You cannot use quotations within inline CSS. If you use quotations the
browser will interpret this as an end of your style value.
• These styles cannot be reused anywhere else.
• These styles are tough to be edited because they are not stored at a
single place.
• It is not possible to style pseudo-codes and pseudo-classes with inline
CSS.
• Inline CSS does not provide browser cache advantages.
Question
Which type of CSS is used in the below code?
<p style = "border:2px solid red;">
A. max-width property
B. height property
C. max-height property
D.position property
<div> element
• The span is similar to the div tag. Both of them divide the
content into individual sections.
• The difference is that span goes into a refined level so that by
using span a single character is formatted if required.
• It is used for text-level element and not for a block-level
element.
• There is no line feed after the </span> tag.
• It is used as a selector in style sheet and it includes STYLE class
and ID as its attribute.
• It is a CSS element and used purely to apply style.
• It has no effect when style sheet is disabled.
What will be the program code?
What will be the program code?
How to create a Power grid webpages using
external css
How to create webpages using internal css
Navigation Bars
33
Example
ul {
list-style-type: none; (Removes the bullets. No
need list markers )
margin: 0; (To remove browser default settings)
padding: 0;
}
<Style>…….</style>
34
What will be the code?
35
CSS Dropdown Menus
• Description
• The Dropdown menu is used for displaying the links in a list format.
• Create a dropdown box that appears when the user moves the mouse over an element.
<div class="Dropdown">
</div>
36
What will be the program code for this?
37
Media queries
• Media queries are for different style rules for different size devices
such as mobiles, desktops, etc.
• Understanding CSS Media Types and Queries
• CSS Media Types and Queries help the user to define certain
styles in accordance with a device’s general type (screen, print,
etc.) or its characteristics (screen resolution, viewport dimensions,
etc.)
• Syntax
@media not | only mediatype and (expressions) {
CSS-Code;
}
38
Example
• <link rel="stylesheet" media="print and|not|only (expressions)"
href="print.css">
39
Question
Which of the following media feature describes the number of
entries in the color lookup table of the output device
a) color b) color-index
c) color-value d) color-@media
40
Question
Which of the following Viewport Property sets the initial scaling
factor?
a) scale b) initial-scale
c) minimum-scale d) user-scale
41
Question
• Which of the following @viewport Property sets the viewport
height in the same way as width?
a) height b) width
42
What will be the program code for this.
Grid
• To design a web page, you can also follow the Grid Layout
Module, i.e. a grid with rows and columns.
• Grid Layout has grid elements, rows, columns, gaps, etc.
• Grid Layout has parent and child elements.
• Rows are the horizontal line of grid items, however, Columns
are the vertical line.
• Using grid you specify one axis using grid-template-rows or
grid-template-columns.
• Then specify how content should auto-repeat in the other axis
using the implicit grid properties: grid-auto-rows, grid-auto-
columns, and grid-auto-flow.
44
Example
• Make a three columns grid layout where the first row is
150px high:
• .grid-container {
display: grid;
grid: 150px / auto auto auto;
}
45
Browser compatibility
46
The Grid Property
• Grid-template-rows
• Grid-template-columns
• Grid-template-areas
• Grid-auto-rows
• Grid-auto-columns
• Grid-auto-flow
47
Grid CSS demonstration
48