udemy CSS Properties
udemy CSS Properties
JavaScript in HTML
<html>
<head>
<script src=“file.js”>// External JS File</script>
</head>
<body> </body>
</html>PHP in HTML
The main objective of CSS is to add styles to HTML. CSS describes how HTML elements are displayed on a
page.
Styling includes colors, fonts, size, borders, background color, padding, margin, bordercolor, and many
more, to style a webpage.
Each CSS property is separated by a semicolon (;)
Three ways to apply CSS
We can define style in 3 ways
1) In Line
2) By using <style> tag inside the <HEAD> TAG
3) By using external .css file
How to define Comments in CSS File:
/* This is CSS comment */
Multiple Classes
<style>
.fruit{
background-color: orange; <body>
color: white; <p> All three elements have the class name
padding: 10px; "fruit". In addition, Mango also has the class
} name "center", which center-aligns the
text</p>.
.center{ <h2>class="fruit">Orange</h2>
text-align: center; <h2>class="fruit">Apple</h2>
} <h2>class="fruit center">Mango</h2>
</style> </body>
You can see that mango belongs to both the "fruit" class and the "center" class, unlike the other fruits.
1. Various Possible Ways to Specify Color:
1) color: red;
2) color:rgb(244,66,220);
we have to collect values from Google Color Picker
The allowed values are 0 to 255
(0,0,0) = black AND (255,255,255) = white
3) color:rgba(244,66,220,0.9)
a means alpha
The allowed values for an attribute are: 0.0 to 1.0
1.0 means full dark and 0.0 means full light (transparent)
NB// USE THIS LINK FOR COLOR CODE TO USE IN RGBA
http://www.december.com/html/spec/colorrgbadec.html
2. Setting Background and Borders:
In CSS, we can set Background as follows:
body{
background-color:red;
}
We can set Border as follows:
div {
border-color: blue;
border-width: thick;
border-style: double;
}
The allowed values for border-width are: medium, thin, thick.
We can also set our own width with pixels. Eg: border-width:10px;
The allowed values for border-style are: dashed, dotted, groove, double etc
3. Color vs Background:
color attribute meant for text color.
background attribute meant for background color
h1{
color: white;
background: blue;
}
4. background image
a. How to set a background image
body {
background:url(https://image.freepik.com/free-psd/abstract-backgrounddesign_1297-73.jpg);
}
b. Various Properties while setting the image
body {
color: white;
background:url(https://image.freepik.com/free-psd/abstract-backgrounddesign_1297-73.jpg);
background-repeat: no-repeat;
background-size: cover;
}
By default, the background image will be repeated. If we don't want to repeat then we should specify:
no-repeat
c. How to Set Border
Normal way:
h1{
border-color: orange;
border-width: 5px;
border-style: solid;
}
short-cut way:
h1{
border: solid red 5px; NB//order is not important
}
To set border for the image:
img{
border: groove 10px blue;
}
HTML
<h1 id="specialh1">Hello This is First Line</h1>
css:
#specialh1{
color: white;
background: blue;
}