LESSON Reviewer
LESSON Reviewer
Advantage of CSS
CSS saves time − You can write CSS once and then reuse same sheet in multiple HTML pages.
Pages load faster − If you are using CSS, you do not need to write HTML tag attributes every time.
Easy maintenance − To make a global change, simply change the style, and all elements in all the web pages will be updated
automatically.
Superior styles to HTML − CSS have much wider array of attributes than HTML, so you can give a far better look to your
HTML page in comparison to HTML attributes.
Multiple Device Compatibility − Style sheets allow content to be optimized for more than one type of device.
Global web standards − Now HTML attributes are being deprecated and it is being recommended to use CSS.
CSS Syntax
A CSS comprises of style rules that are interpreted by the browser and then applied to the corresponding elements in your
document. A style rule is made of three parts.
selector {property: value}
CSS Syntax Rules
selector {property: value}
1. Selector − A selector is an HTML tag at which a style will be applied. This could be any tag like
<h1> or <table> etc.
2. 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.
3. Value − Values are assigned to properties. For example, color property can have value either red or #F1F1F1 etc.
Example:
CSS Selector
1. Element or Type selectors - The element selector selects HTML elements based on the element name.
element {property: value}
2. ID Selector
- The id selector uses the id attribute of an HTML element to select a specific element.
- The id of an element is unique within a page, so the id selector is used to select one unique element.
- To select an element with a specific id, write a hash (#) character, followed by the id of the element.
#id {property: value}
3. Class Selector
- The class selector selects HTML elements with a specific class attribute.
- To select elements with a specific class, write a period (.) character, followed by the class name.
#class {property: value}
Note: The most important difference between ID’s and classes is that there can be only one ID on a page, but multiple
classes. An ID is more specific than a class. An element can have both ID and multiple classes.
4. Universal Selector - Rather than selecting elements of a specific type, the universal selector quite simply matches the
name of any element type.
* {property: value}
5. Descendant Selector
- A way to target elements that are descendants of a specific element.
- It allows you to style elements based on their relationship to another element in the HTML document hierarchy.
- The syntax for the descendant selector is simply placing a space between two selectors.
p d {property: value}
INSERTING A STYLE SHEET
1. Inline Styles
- An inline CSS is used to apply a unique style to a single HTML element.
- An inline CSS uses the style attribute of an HTML element.
<element style=”property: value;”>
2. Internal Style Sheet - Internal styles are defined within the section of an HTML page.
<style> selector {property:value} <style>
3. External Style Sheet
- Styles are specified in an external CSS file.
- Each page must include a reference to the external style sheet file inside the element.
<head> <link rel=”stylesheet” type=”text/css” href=”mycss.css” <head>
Colors Format
2. Backgrounds - CSS Background properties is used to define the background effects of an element.
List of Background Properties
1. Background-color
- The background-color property specifies the background color of an element.
2. Background-image
- The background-image property specifies an image to use as the background of an element.
3. Background-repeat
- By default, the background-image property repeats an image both horizontally and vertically.\
4. Background-position
- Position of an image can be set by using:
background-position: right top;
3. Shorthand Property - to shorten the code, it is also possible to specify all the background properties in one single
property.
When using the shorthand property, the order of the property values is:
a. background-color
b. background-image
c. background-repeat
d. background-attachment
e. background-position
Example:
body {
background: #00ff00 url(“img_tree.jpeg”) no-repeat right top;
}
4. Text Color - color property is used to set the color of the text.
Example:
H1{
background-color: green;
color: white;
}
5. Text Alignment – a property used to set the horizontal alignment of a text.
text-decoration-line: overline underline;
text-decoration-color: blue;
text-decoration-style: dashed;
text-decoration-thickness: 5px;
Shorthand Property:
p{
text-decoration: overline underline purple dashed 10px;
}
6. Text Transformation – the text-transform property is used to specify uppercase and lowercase letters in a text.
text-transform: uppercase; (to all caps)
text-transform: lowercase; (to small)
text-transform: capitalize; (first letter cap)
8. Font Family - this should hold several font names as a "fallback" system, to ensure maximum compatibility
between browsers/operating systems.
Example:
font-style: normal;
font-style: italic;
font-style: oblique;
Example:
font-weight: normal;
font-weight: bold;
Absolute size:
Relative size:
12. Margins – To the CSS margin properties are used to create space around elements, outside of any defined
borders.
Example:
margin-top: 100px;
margin-bottom: 100px;
margin-right: 150px;
margin-left: 80px;
Shorthand Property:
13. Padding - the CSS padding properties are used to generate space around an element's content, inside of any
defined borders.
Example:
padding-top: 50px;
padding-right: 30px;
padding-bottom: 50px;
padding-left: 80px;
Shorthand Property:
What is Bootstrap
Bootstrap is a powerful front-end framework for faster and easier web development.
Bootstrap gives the ability to create flexible and responsive web layouts with much less efforts.
History of Bootstrap
Responsive web design is about creating web sites which automatically adjust depends on the screen.
Bootstrap's grid system is built with flexbox and allows up to 12 columns across the page
The grid system is responsive, and the columns will rearrange automatically depending on the screen size.
If you do not want to use all 12 columns individually, you can group the columns together to create wider columns:
Bootstrap Breakpoints
Extra Small (xs): Used for screens smaller than 576 pixels. This is typically the default styling for mobile devices.
Small (sm): Used for screens equal to or larger than 576 pixels. This is commonly used for small tablets and larger
mobile devices.
Medium (md): Used for screens equal to or larger than 768 pixels. This is typically used for larger tablets and small
laptops.
Large (lg): Used for screens equal to or larger than 992 pixels. This is commonly used for larger laptops and desktops.
Extra Large (xl): Used for screens equal to or larger than 1200 pixels. This is typically used for larger desktop
monitors.
Responsive web design is a process of designing and building websites to provide better accessibility and optimal
viewing experience to the user by optimizing it for different devices.