What is CSS
What is CSS
What is CSS
</body>
</html>
Text properties
Text Align: Aligns text (center, justify, left, right).
Text Decoration: Underlines the text.
Text Color: Changes the text color.
Text Transform: Transforms text (uppercase, lowercase,
capitalize).
Text Shadow: Adds a shadow effect to the text.
Text Indent: Creates space at the start of the paragraph.
Line Height: Adjusts the space between lines for
readability.
Word Break: Controls how words break when they reach
the end of a line.
• Text Alignment
• The text-align property is used to set the horizontal
alignment of a text.
• A text can be left or right aligned, centered, or
justified.
text-align: center; /* options: left, right, justify */
• Text Decoration
Adds decoration to the text, like underline or line-
through.we can also specify the color
text-decoration: underline; /* options: none, overline,
line-through */
text-decoration-color: red;
• Text Color
• The color property is used to set the color of
the text. The color is specified by:
• a color name - like "red"
• a HEX value - like "#ff0000"
• an RGB value - like "rgb(255,0,0)"
• Text Transform
Manipulates the case of the text.
• text-transform: uppercase; /* options:
lowercase, capitalize, none */
Basic Colors
White: #FFFFFF
Black: #000000
Red: #FF0000
Green: #008000
Blue: #0000FF
Yellow: #FFFF00
Cyan: #00FFFF
Magenta: #FF00FF
Extended Colors
Light Gray: #D3D3D3
Dark Gray: #A9A9A9
Orange: #FFA500
Purple: #800080
Brown: #A52A2A
Pink: #FFC0CB
Example Colors
Light Blue: #ADD8E6
Lime Green: #32CD32
Gold: #FFD700
Teal: #008080
Navy Blue: #000080
• Text Shadow
Adds shadow effects to the text.
In its simplest use, you only specify the
horizontal shadow (2px) and the vertical shadow
(2px):
add a color (red) to the shadow:
• text-shadow: 2px 2px red;
• h1 { text-shadow: 2px 2px red;}
•
• add a blur effect (5px) to the shadow:
text-shadow: 1px 1px 2px red
<body>
<h1>This is a heading</h1>
<p>This is a paragraph</p>
<p>This is another paragraph</p>
</body>
• Line Height
Controls the space between lines of text.
• line-height: 1.5; /* can be a number, unitless,
or px */
• Letter Spacing
Adjusts the space between characters.css
• letter-spacing: 2px;
• Word Spacing
Changes the space between words.
• word-spacing: 5px;
• Text Indent
The text-indent property is used to specify the indentation of the
first line of a text block.
• text-indent: value;
p{
text-indent: 20px; /* Indents the first line by 20 pixels */
}
• Word Break
The word-break property specifies how words should break when
reaching the end of a line. n CSS, the word-break property is used to
control how words are broken or wrapped when they reach the end
of a line. This property can help manage text layout in situations
where long words might cause overflow issues or disrupt the flow
<!DOCTYPE html>
<html lang="en">
<head>
<title>Text Properties Example</title>
</head>
<body style="font-family: Arial, sans-serif; background-color: #f4f4f4; padding: 20px;">
<h1 style="text-align: center; color: #2c3e50; text-transform: uppercase; text-shadow: 1px 1px 2px
rgba(0, 0, 0, 0.5);">
Welcome to Text Properties
</h1>
<p style="text-align: justify; text-decoration: underline; color: #2980b9; line-height: 1.6; text-indent:
20px;">
This paragraph demonstrates several text properties. It is underlined, justified, and has a blue color.
The line height is increased for better readability, and there's an indent at the beginning.
</p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>The Solar System</title>
<style>
.uppercase {
text-transform: uppercase;
}
p{
color: green;
text-indent: 50px;
}
.big {
line-height: 1.8;
}
h1 {
text-align: center;
text-decoration: line-through;
text-shadow: 3px 2px yellow;
}
h2 {
text-align: left;
text-decoration: overline;
color: #ff0000;
}
h3 {
text-align: right;
text-decoration: underline;
}
</style>
</head>
<body>
<h1 style="color: blue;">The Solar System</h1>
<h2>Planets</h2>
<p class="uppercase">There are eight planets in our solar system. These are Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, and
Neptune. Earlier, Pluto was also considered a planet, but in recent years it was excluded from the planets list and was considered a dwarf
planet.</p>
<h3>Satellites</h3>
<p class="big">You know that the Earth revolves around the Sun. It is a heavenly body commonly referred to as a planet. Similar to a planet
revolving around the Sun, there are smaller heavenly bodies that revolve around the planets. These are known as satellites. Our Earth also has
a satellite; we call it the Moon.</p>
</body>
</html>
In this the satellite is aligned to the right because in
css the default syntax of h3 is
h3 {
text-align: right;
text-decoration: underline;
}
So if you need to change to center you need to
specify it as center
<h3 style="text-align: center;">Satellites</h3>
Choosing the right font has a huge impact on
how the readers experience a website.
• font-family
Specifies the typeface(design) for the text. We
use font family to specify the font of a text.
It has a list of fonts
• Syntax :: font-family: value
• font-family: Arial, sans-serif;
Family name is the name of the font
Eg: Aria,Times New Roman etc…
• Generic Family: are the group of family names
with uniform appearances.
These include:
• serif: Fonts with small lines at the ends of
characters (e.g., Times New Roman).
• sans-serif: Fonts without the small lines (e.g.,
Arial).
• monospace: Fonts with fixed-width characters
(e.g., Courier New).
• cursive: Fonts that resemble handwritten text.
• fantasy: Decorative fonts.
• font-size
Sets the size of the font. Default font size is 16px(parent font)
• font-size: 16px; /* Can also use em, rem, percentages */
• Font Size
• Font size determines the size of text in your web pages. It can be
specified in several ways:
Pixels (px): A fixed size (e.g., 16px).
Points (pt): Primarily used in print media (1pt = 1/72 inch).
Percentages (%): Relative to the parent element's font size.
Ems (em): Relative to the font size of the element itself or its parent.
Rems (rem): Relative to the font size of the root element (typically
<html>).
h1{font-size:2.5em;}
h2{font-size:1.8em;}
1em is equal to the current font size. The default text size in
browsers is 16px. So, the default size of 1em is 16px.
• h1 { font-size: 2.5em; }:
– This sets the font size of all <h1> elements to 2.5em.
– Since 1em equals the font size of the parent element (in this case, the
<body>), the size of the <h1> will be 2.5 times the size of the body
font.
– If the body font size is 16px, then the <h1> size would be 2.5 * 16px =
40px.
• h2 { font-size: 1.8em; }:
– This sets the font size of all <h2> elements to 1.8em.
– Similarly, this means the <h2> size will be 1.8 times the body font size.
– Using the same body font size of 16px, the <h2> size would be 1.8 *
16px = 28.8px.
• font-style
• The font-style property is mostly used to specify
italic text.
• This property has three values:
• normal - The text is shown normally
• italic - The text is shown in italics
• oblique - The text is "leaning" (oblique is very
similar to italic, but less supported)
• font-style: italic; /* or normal/oblique */
• The font shorthand property in CSS allows you to
set several font-related properties in a sing
font: [font-style] [font-size] [font-family];
<!DOCTYPE html>
<html lang="en">
<head>
<title>Font Style Example</title>
<style>
body {font-family: Arial, sans-serif;margin: 20px;background-
color: #f0f0f0;}
h1 {font: italic bold 32px "Georgia", serif;color: #2c3e50;}
p {font: normal normal 16px/1.5 "Verdana", sans-serif;color:
#34495e;}
</style>
</head>
<body>
<h1>Welcome to the Font Style Example</h1>
<p>This paragraph demonstrates the use of different font
properties.</p>
<p>Using the shorthand method allows for a cleaner and
more organized CSS.</p>
</body>
</html>
Border properties
border-width
Specifies the width of the border. You can use values in px, em, rem, etc.
border-width: 2px;
border-style
Defines the style of the border. Common values include:
none: No border.
solid: A solid border.
dashed: A dashed border.
dotted: A dotted border.
double: A double border.
groove: A 3D groove effect.
ridge: A 3D ridge effect.
inset: A 3D inset effect.
outset: A 3D outset effect.
border-style: solid;
dashed {
border: 2px dashed black;
}
.dotted {
border: 2px dotted black;
}
.double {
border: 4px double black;
}
.groove {
border: 4px groove black;
}
.ridge {
border: 4px ridge black;
}
.inset {
border: 4px inset black;
}
.outset {
border: 4px outset black;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Div Example</title>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Different Border Types Without Div</title>
</head>
<body>
</body>
</html>
• border-color
• Specifies the color of the border. You can use
named colors, hex codes, RGB, or RGBA
values.
• border-color: #ff0000;
<!DOCTYPE html>
<html lang="en">
<head>
<title>Border Properties</title>
<style>
h1 {
text-align: center;
border-style: dashed;
border-width: 1.5px;
border-color: red;
border: 1.5px dashed red;
padding: 10px;
} p{
text-align: justify;
border: 1.5px solid coral;
background-color: lightyellow;
padding: 10px;
}
</style>
</head>
<body>
<h1 style="color: blue;">The Sun</h1>
<p style="color: green;">The Sun is at the center of the solar system. <br> All the
planets and the other heavenly bodies revolve around it.</p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Border Properties Example</title>
<style>
div {
border-width: 5px;
border-style: dashed;
border-color: #ff5733;
border-radius: 10px;
padding: 20px;
margin: 20px;
background-color: #f9f9f9;
text-align: center;
}
</style>
</head>
<body>
<div>
This is a box with dashed borders!
</div>
</body>
</html>