note4
note4
-----------------------------------------
We can use div and span tags to group related tags into a single unit.
In general we can use these tags with CSS.
Ex:-
1) <div class="groupone">
2) <h1> Group One Content</h1>
3) <p>This division tag helpful to style a group of
4) html tags with css</p>
5) </div>
CSS
--------------------
The main objective of CSS to add styles to HTML. CSS describes how HTML elements
are displayed
on a page.
Styling includes colors,fonts,size,borders etc
We can define CSS styling inside HTML. But it is highly recommended to define
styling inside a
seperate CSS file(.css extension) and link that file to HTML.
The power of CSS demo link:
https://www.w3schools.com/Css/css_intro.asp
Various ways to define Style for HTML Elements:
We can define style in 3 ways
1. In Line
2. By using style tag
3. By using css file
1. In Line:
---------------
<h1 style="color:red">This is My First Part of Data</h1>
define style at tag level is not recommended b'z it increases complexity as every
html page
contains 1000s of tags
<head>
<link rel="stylesheet" href="style1.css">
</head>
We can reuse same css file for every html page so that we can promote code
reusability. Hence
this approach is highly recommended to use.
Once we defined css file, we can link it to html by using <link> tag inside <head>
part of html.
<head>
<link rel="stylesheet" href="form.css">
</head>
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
(255,255,255)-->white
3. color:#f44e42
This 6-digit number represents hexa code of color
color vs background:
-----------------------------
color attribute meant for text color
background attribute meant for background color
h1{
color:white;
background:blue;
}
h1{
border-color: orange;
border-width: 5px;
border-style: solid;
}
short-cut way:
h1{
border: solid red 5px; order is not important
}
2. ID Selectors:
Selects an element with the given Id. But with in the HTML Page ID is always
unique.
html:
<h1 id="specialh1">Hello This is First Line</h1>
css:
#specialh1{
color:white;
background: blue;
}
3. Class Selector:
Select all elements with the given class.
html:
<body>
<h1 class="specialh1">Hello This is First Line</h1>
<h1>Hello This is Second Line</h1>
<h1 class="specialh1">Hello This is Third Line</h1>
</body>
css:
1) specialh1{
2) color:white;
3) background: blue;
4) }
Note: element,id and class selectors are considered as basic css selectors.
1. font-family:
We can select desired font from default css system fonts in the following link
https://www.cssfontstack.com/
Eg:
h1{
font-family: Arial Black;
}
Note: If we are not satisfied with default css system fonts, then we can use
external fonts also.
2. font-size:
p{
font-size: 20px;
}
We can also specify font-size in em units, which is also known as dynamic font-size
(relative fontsize)
Eg:
span{
font-size: 2.0em;
}
3. font-weight:
p{
font-weight: 600;
}
4. line-height:
The space between 2 lines is called line height.
p{
line-height: 1.5;
}
5. text-align:
p{
text-align:center;
}
The allowed values are: left,rigth,center,justify
6. text-decoration:
like underlined,strike through
Eg:
p{
text-decoration: line-through;
}
The allowed values are: underline, overline, line-through