Cascading Style Sheets is a style sheet language used for specifying the presentation and styling of a document written in a markup language such as HTML or XML. CSS is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript.
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Intro to CSS_APEC CascadingStyleSheets.pptx
1.
2. Dr. N. SIVAKUMAR
B.Tech, M.Tech, MHRM, MBA, Ph.D
Assistant Professor, CSE
Pondicherry Engineering College
2
3. Cascading Style Sheet (CSS)
• CSS stands for Cascading Style Sheet.
• CSS is used to design HTML tags.
• CSS describes how HTML elements should be displayed.
4. Why CSS ?
• Create Stunning Web site
• CSS saves time
• Pages load faster
• Easy maintenance
• Superior styles to HTML
5. <html>
<head>
<title>Sample</title>
</head>
<body>
<h1> About Us </h1>
<p>
TechMyths Software Solutions is a
software development Company that
provides cutting edge engineering
solutions and offers IT- enabled
services.
</p>
<h1> Our Services </h1>
<p>
Quality in a Service (or) product is
not what you put into it - It is what
the client (or) customer gets out of it.
</p>
</body>
</html>
Code
7. <html>
<head>
<title>Sample</title>
</head>
<body>
<h1 style="color:red"> About Us
</h1>
<p>
TechMyths Software Solutions is a
software development Company that
provides cutting edge engineering
solutions and offers IT- enabled
services. </p>
<h1 style="color:red"> Our
Services </h1>
<p>
Quality in a Service (or) product is
not what you put into it - It is what
the client (or) customer gets out of
it.
</p>
</body>
</html>
Code
9. <html>
<head>
<title>Sample</title>
<style>
h1 { color: red; }
</style>
</head>
<body>
<h1> About Us </h1>
<p>
TechMyths Software Solutions is a software development Company that
provides cutting edge engineering solutions and offers IT- enabled services.
</p>
<h1> Our Services </h1>
<p>
Quality in a Service (or) product is
not what you put into it - It is what
the client (or) customer gets out of it.
</p>
</body>
</html>
Applying Style Sheets
12. A style rule is made of three parts −
• Selector − A selector is an HTML tag at which a style will be applied. This
could be any tag like <h1> or <table> etc.
• Property − A property is a type of attribute of HTML tag. Put simply, all
the HTML attributes are converted into CSS properties. They could
be color, border etc.
• Value − Values are assigned to properties. For example, color property can
have value either red or #F1F1F1 etc.
13. CSS Selector
• CSS selectors are used to select the content you want to style.
• Selectors are the part of CSS rule set.
• CSS selectors select HTML elements according to its id, class, type, attribute
etc.
14. Types of Selectors in CSS
1. CSS Element Selector
2. CSS Id Selector
3. CSS Class Selector
4. CSS Universal Selector
5. CSS Group Selector
18. CSS Id Selector
• The id selector selects the id attribute of an HTML element to select a
specific element.
• An id is always unique within the page so it is chosen to select a single,
unique element.
• It is written with the hash character (#), followed by the id of the element.
19. <html>
<head>
<style>
#exam {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<h1> About Us </h1>
<p id="exam">This is Techmyths Solutions</p>
<h1> Our Services </h1>
<p>We provide Training</p>
<h1> Contact </h1>
<p id="exam">Pondicherry</p>
</body>
</html>
Code
20.
21. CSS Class Selector
• The class selector selects HTML elements with a specific class attribute.
• It is used with a period character . (full stop symbol) followed by the class
name.
22. <html>
<head>
<style>
.exam {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<h1> About Us </h1>
<p class="exam">This is Techmyths Solutions</p>
<h1 class="exam"> Our Services </h1>
<p class="exam">We provide Training</p>
<h1> Contact </h1>
<p>Pondicherry</p>
</body>
</html>
Code
23.
24. CSS Class Selector for specific element
• If you want to specify that only one specific HTML element should be
affected then you should use the element name with class selector.
25. <html>
<head>
<style>
p.exam {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<h1> About Us </h1>
<p class="exam">This is Techmyths Solutions</p>
<h1 class="exam"> Our Services </h1>
<p class="exam">We provide Training</p>
<h1> Contact </h1>
<p>Pondicherry</p>
</body>
</html>
Code
26.
27. CSS Universal Selector
• The universal selector is used as a wildcard character.
• It selects all the elements on the pages.
28. <html>
<head>
<style>
* {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<h1> About Us </h1>
<p class="exam">This is Techmyths Solutions</p>
<h1 class="exam"> Our Services </h1>
<p class="exam">We provide Training</p>
<h1> Contact </h1>
<p>Pondicherry</p>
</body>
</html>
Code
29.
30. CSS Group 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.
32. <html>
<head>
<style>
h1,p {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<h1> About Us </h1>
<p>This is Techmyths Solutions</p>
<h1> Our Services </h1>
<p>We provide Training</p>
<h2> Contact </h2>
<p>Pondicherry</p>
</body>
</html>
Code
33.
34. How To Add CSS ?
There are three ways of inserting a style sheet:
• Inline CSS
• Internal CSS
• External CSS
35. Inline CSS
• An inline style may be used to apply a unique style for a single element.
• To use inline styles, add the style attribute to the relevant element.
• The style attribute can contain any CSS property.
• Inline styles are defined within the "style" attribute of the relevant element.
36. <html>
<body>
<h1 style="color:blue;text-align:center;">Techmyths Solutions</h1>
<p style="color:red;">
TechMyths Software Solutions is a software development Company
that provides cutting edge engineering solutions and offers IT-
enabled services. Our team assists in transforming the business
through latest tech capabilities to stay ahead of the curve.
</p>
</body>
</html>
Inline CSS - Code
37.
38. Internal CSS
• An internal style sheet may be used if one single HTML page has a unique
style.
• The internal style is defined inside the <style> element, inside the head
section.
41. External CSS
• With an external style sheet, you can change the look of an entire website by
changing just one file!
• Each HTML page must include a reference to the external style sheet file
inside the <link> element, inside the head section.
• An external style sheet can be written in any text editor, and must be saved
with a .css extension.
• The external .css file should not contain any HTML tags.
44. Multiple Style Sheets
• Assume that an external style sheet has the following style for the <h1> element:
h1 {
color: navy;
}
• Then, assume that an internal style sheet also has the following style for the <h1>
element:
h1 {
color: orange;
}
47. CSS Cascading Order
• What style will be used when there is more than one style specified for an
HTML element?
• All the styles in a page will "cascade" into a new "virtual" style sheet by the
following rules, where number one has the highest priority:
• Inline style (inside an HTML element)
• External and internal style sheets (in the head section)
• So, an inline style has the highest priority, and will override
external and internal styles.
50. CSS Comments
• Comments are used to explain the code, and may help when you edit the
source code at a later date.
• Comments are ignored by browsers.
• A CSS comment is placed inside the <style> element, and
starts with /* and ends with */:
51. <style>
/* This is a single-line comment */
p {
color: red;
}
</style>
CSS Comments
<style>
/* This is
a multi-line
comment */
p {
color: red;
}
</style>
Single line comment Multi-line comment
52. CSS Color Names
In CSS, a color can be specified by using a predefined color name:
54. CSS RGB Colors
• An RGB color value represents RED, GREEN, and BLUE light sources.
• In CSS, a color can be specified as an RGB value, using this formula:
rgb(red, green, blue)
• Each parameter (red, green, and blue) defines the intensity of the color between 0 and 255.
• For example, rgb(255, 0, 0) is displayed as red, because red is set to its highest value (255) and
the others are set to 0.
• To display black, set all color parameters to 0, like this: rgb(0, 0, 0).
• To display white, set all color parameters to 255, like this: rgb(255, 255, 255).
58. CSS Background Image
<html>
<head>
<style>
body {
background-image: url("grey.jpg");
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<p>This page has an image as the
background!</p>
</body>
</html>
59.
60. CSS Borders
• The CSS border properties allow you to specify the style, width, and color of
an element's border.
• The border-style property specifies what kind of border to display.
The following values are allowed:
dotted - Defines a dotted border
dashed - Defines a dashed border
solid - Defines a solid border
double - Defines a double border