Unit 2-Css and HTML
Unit 2-Css and HTML
Looping
Outline HTML Outline CSS
Introduction to HTML What is CSS?
What is a Web Page? Syntax and structure of CSS
My First HTML Page CSS rules for Backgrounds, Colors and
HTML Code Formatting properties
Basic HTML Tags Manipulating texts, Fonts
Heading The Box Model
Paragraph
borders and boxes
Color
Margins and Padding
Font
List Lists
Anchor CSS Positioning and Float Property
Image Animations
HTML Tables Tooltip
HTML Forms Style images
HTML Meta tags Variables
Media tags Media Queries
HTML 5 tags and validation Wildcard Selectors (*, ^ and $) in CSS
Working with Gradients, Pseudo Class
Pseudo elements
What is a Web Page?
A webpage is a document, commonly written in HTML, that is viewed in an
Internet browser.
HTML – Hyper Text Markup Language is the notation for describing
document structure (semantic markup)
formatting (presentation markup)
A web page can be accessed by entering a URL into a browser's address
bar.
A web page may contain text, graphics, and hyperlinks to other web
pages and files.
The first web page was created at CERN by Tim Berners-Lee on August 6,
1991.
You can visit and browse the first website and the first web page at the
info.cern.ch address.
Creating HTML Pages
An HTML file must have an .htm or .html file extension
HTML files can be created with text editors:
NotePad, NotePad ++, PSPad
Or HTML editors (WYSIWYG Editors):
Microsoft FrontPage
Macromedia Dreamweaver
Netscape Composer
Visual Studio
Open any above mentioned editors and create a new file with .html
extension and save the file.
After saving the file you can open the file with any Web Browser in order
to view the output.
First HTML Page
test.html
<!DOCTYPE HTML>
<html>
<head>
<title>My First HTML Page</title>
</head>
<body>
<p>This is some text...</p>
</body>
</html>
HTML Structure
HTML is comprised of “elements” and “tags”
Begins with <html> and ends with </html>
Elements (tags) are nested one inside another:
<html> <head></head> <body></body>
Tags</html>
have attributes:
<img src="logo.jpg" alt="logo" />
HTML describes structure using two main sections: <head> and <body>
The HTML source code should be formatted to increase readability and
facilitate debugging.
Every block element should start on a new line.
Every nested (block) element should be indented.
Browsers ignore multiple whitespaces in the page source, so formatting is harmless.
For performance reasons, formatting can be sacrificed
First HTML Page
<!DOCTYPE HTML> HTML header
<html> Opening tag
<head>
<title>My First HTML Page</title>
</head>
Closing tag
<body>
<p>This is some text...</p>
</body>
</html>
HTML body
Basic HTML Tags
1. Headings
2. Paragraph
3. Colors
4. Fonts
5. List
6. Anchor Tag
7. Image
8. Table
9. Form
1) Headings
Headings are important because search engines use the headings to index
the structure and content of your web pages.
o Block-A Block-A
Unordered
o Block-B Block-B
List
o Block-C Block-C
• Block-A
o Block-D Block-D
• Block-B
• Block-C
• Block-D
5.1) Ordered List (OL)
<ol> Types:
<li> Item one </li>
<li> Item two </li> Type = 1
<ol type="I"> (default)
<li> Sublist item one </li> Type = a
<li> Sublist item two </li> Type = A
<ol type="i"> Type = I
<li> Sub-sub list item one </li> Type = i
<li> Sub-sub list item two </li>
</ol>
</ol> Output
</ol>
5.2) Unordered List (UL)
<ul>
<li> One </li> Types:
<li> Two </li> Type = disc
<ul type="circle"> (default)
<li> Three </li> Type = circle
<li> Four </li> Type = square
<ul type="square">
<li> Five </li> Output
<li> Six </li>
</ul>
</ul>
</ul>
6) <a> Anchor Tag (Hyperlinks)
The <a> tag defines a hyperlink, which is used to link from one page to
another.
An Anchor tag have 3 important attributes:
the href attribute (hypertext reference) defines the target address of the document.
the name attribute of the anchor tag can be used to enable users to “jump” to a
specific point on a page.
the target attribute specifies how the destination page or the target document
should be opened. target="_ blank" is used for opening of the target page in a
new tab.
Link to an absolute URL:
Example, <a href="http://www.darshan.ac.in"> Darshan </a>.
Link to a relative URL:
Example, <a href=“./index.php"> Home </a>.
Link to a section within a URL:
Example, <a href=“#reference"> Reference Section. </a>.
7) Images
The HTML <img> element embeds an image into the document.
Syntax: <img src= "pathToImage" />
Attributes:
the src attribute is required, and contains the path to the image we want to embed.
the alt attribute holds a text description of the image, which isn't mandatory but is
incredibly useful for accessibility (screen readers read this description out to their
users so they know what the image means). Alt text is also displayed on the page if
the image can't be loaded for some reason: for example, network errors, content
blocking etc…
the width & height attribute can be in units of pixels or percentage of page or
frame.
the align attribute (currently deprecated) will aligns the image with its surrounding
context (Use the float and/or vertical-align CSS properties instead of this attribute).
8) Table
<table border=1> <table> table tag
<caption>Table Caption</caption>
<caption> optional table title
<tr> <tr> table row
<th>Heading1</th> <th> table header
<th>Heading2</th> <td> table data element
</tr>
<tr> Output
<td>Row1 Col1 Data</td>
<td>Row1 Col2 Data</td>
</tr>
<tr>
<td>Row2 Col1 Data</td>
<td>Row2 Col2 Data</td>
</tr>
</table>
HTML Forms
HTML forms are used to create GUIs on Web pages
• Usually the purpose is to ask the user for information
• The information is then sent back to the server
A form is an area that can contain form elements
• The syntax is: <form parameters> ...form elements... </form>
• Form elements include: buttons, checkboxes, text fields, radio buttons, drop-down
menus, etc
• Other kinds of HTML tags can be mixed in with the form elements
• A form usually contains a Submit button to send the information in the form elements
to the server
• The form’s parameters tell browser how to send the information to the server (there
are two different ways it could be sent)
The <form> Tag
The <form parameters> ... </form> tag encloses form elements (and
probably other HTML as well)
The parameters to form tell what to do with the user input
• action="url" (required)
• Specifies where to send the data when the Submit button is clicked
• method="get" (default)
• Form data is sent as a URL with ?form_data info appended to the end
• Can be used only if data is all ASCII and not more than 100 characters
• method="post"
• Form data is sent in the body of the URL request
• Cannot be bookmarked by most browsers
• target="target"
• Tells where to open the page sent as a result of the request
• target= _blank means open in a new window
• target= _top means use the same window
Form Elements
Input Input Types Input Types
(HTML4) (HTML5)
Select text number
password email
Textarea
checkbox search
Button radio url
submit tel
Label button range
reset color
Fieldset
file date
Legend time
datetime-local
Etc… month
week
HTML5 Form Validation
Form validation is a “technical process where a web-form checks if the
information provided by a user is correct.”
The form will either alert the user that something is not in correct format
and need to fix to proceed, or the form will be validated and the user will
be able to continue with their process.
Form can be validated both in Client-Side as well as Server-Side, it is
recommended to validate the form in both the side.
Form validation generally performs two functions.
1. Basic Validation
Emptiness
Length Validation etc……
2. Data Format Validation
Secondly, the data that is entered must be checked for
correct form and value.
Email Validation
Mobile Number Validation
HTML5 Form Validation (Cont…)
We can use required attribute in order to stop user sending empty data
to 1server.
<input type="text" name="txtName" require
d/>
<h1> Output
How are you Hello Friends
</h1> How are you
The “class” selector
The class selector is used to specify a style for a group of elements.
The class selector uses the HTML class attribute, and is defined with a ".“
in css.
HTML CSS
<h1 class=“myClass”> .myClass{
Hello Friends color: blue;
</h1> }
<h1>
How are you
</h1> Output
<h1 class=“myClass”> Hello Friends
How are you How are you
</h1> How are you
Different ways to write CSS
There are three ways of writing a style sheet:
1. Inline Style
2. Internal/Embedded Style sheet
3. External Style Sheet
1) Inline Style
It is possible to place CSS right in your HTML code, and this method of CSS
usage is referred to as inline css.
Inline CSS has the highest priority out of external, internal, and inline
CSS.
This means that you can override styles that are defined in external or
internal by using inline CSS.
If you want to add a style inside an HTML element all you have to do is
specify the desired CSS properties with the style HTML attribute.
Example: HTML
<p style="background: blue; color: white;"> My Inline CSS
</p>
2) Internal Style Sheet
This type of CSS is only for Single Web Page.
When using internal CSS, we must add a new tag, <style>, inside the
<head> tag.
The HTML code below contains an example of <style>'s usage.
HTML
<html><head>
<style type="text/css">
p{ color: red;}
</style>
</head><body>
<p>Your page's
content!</p></body>
</html>
3) External Style Sheet
When using CSS it is preferable to keep the CSS separate from your
HTML.
Placing CSS in a separate file allows the web designer to completely
differentiate between content (HTML) and design (CSS).
External CSS is a file that contains only CSS code and is saved with a
".css" file extension.
This CSSDemo.html
file is then referenced in your test.css
HTML using the <link> instead of
<html> #para1{
<style>.
<head> text-align: center;
<link rel=“stylesheet” }
type=“text/css” p
href=“test.css”> {
</head> color : blue;
<body> }
<p> Hello Friends </p>
<p id=“para1”> How are Output
you? </p> Hello Friends
</body> How are you?
</html>
3) External Style Sheet (Cont.)
Advantages:
It keeps your website design and content separate.
It's much easier to reuse your CSS code if you have it in a separate file. Instead of
typing the same CSS code on every web page you have, simply have many pages
refer to a single CSS file with the "link" tag.
You can make drastic changes to your web pages with just a few changes in a single
CSS file.
Assign Multiple Classes
We can apply different class to same html element by giving space
separated class names in the class attribute:
Demo.html test.css
<html> . class1
<head> {
<link rel=“stylesheet” color : blue;
type=“text/css” }
href=“test.css”> . class2
</head> {
<body> text-align : center;
}
<h1 class=“class1 class2”>
How are you? Output
</h1>
How are you?
</body>
</html>
Multiple Selection
We can apply same css to multiple selectors using comma separated
selector Demo.html
list, for example : test.css
<html> p, h1
<head> {
<link rel=“stylesheet” color : blue;
type=“text/css” }
href=“test.css”>
</head>
<body>
</body>
How are you?
</html>
Multi-level Selection
We can use hierarchical path to target html element by space
separated element/class/id names, for example :
Demo.html test.css
<html> div h1
<head> {
<link rel=“stylesheet” color : blue;
type=“text/css” }
href=“test.css”>
</head>
<body>
<h1>Hello Friends…</h1>
<div> Output
<h1>How are Hello Friends…
you?</h1>
</div>
How are you?
</body>
</html>
Background Property
Property Name
Margin
Border
Padding
Content
The Box Model (Cont)
margin-top
border-top
padding-top
padding-right
margin-right
border-right
padding-left
margin-left
border-left
Content
padding-bottom
border-bottom
margin-bottom
CSS Padding
The CSS padding properties define the space h4{
between the element border and the element padding : 10px;
}
content.
h4{
The top, right, bottom, and left padding can be padding-top : 10px;
padding-right :
changed independently using separate 20px;
properties. padding-bottom : 30
px;
padding-left : 40 px;
}
h4{
padding : 10px 20px
30px 40px;
A shorthand padding property can also be used, }
to change all padding at once.
CSS Border
• The CSS border properties allow you to specify the h4{
style and color of an element's border. border : 1px solid
red;
• Border Style Types }
h4{
• The border-style property specifies what kind of border border-style : solid;
to display. border-style :
• Border Width dotted;
border-style :
• The border-width property is used to set the width of double;
the border. h4{
}
border-width : 7px;
• Border Color }
• The border-color property is used to set the color of the
h4{
border.
border-color : red;
• Border colors can be any color defined by RGB, }
hexadecimal, or key terms. Below is an example of
each of these types. h4{
border-top : 1px
• The top, right, bottom, and left border can be solid red;
changed independently using separate properties. }
CSS Margin
• The CSS margin properties define the h4{
margin: 10px;
space around elements }
h4{
• The top, right, bottom, and left margin margin -top : 10px;
can be changed independently using margin -right : 20px;
margin -bottom : 30
separate properties. px;
margin -left : 40 px;
}
h4{
margin : 10px 20px 30px
40px;
}
• A shorthand margin property can also
be used, to change all margins at once.
CSS Positioning
• Absolute Positioning
h1{
• With absolute positioning, you define the exact pixel position : absolute;
value where the specified HTML element will left : 50px;
appear. top : 100px;
• The point of origin is the top-left of the browser's }
viewable area, so be sure you are measuring from h1{
that point. position : relative;
• Relative Positioning left : 50px;
• Relative positioning changes the position of the top : 100px;
HTML element relative to where it normally appears }
• Fixed Positioning h1{
• The element is positioned relative to the browser position : fixed;
window, in fixed position, element will be in the top : 50px;
same place even we scroll the screen. left : 100px;
• Sticky Positioning }
• An element with position: sticky; is positioned based h1{
on the user's scroll position. position : sticky;
• A sticky element toggles between relative and fixed, top : 0px;
depending on the scroll position. }
Styling Links
Anchor/Link States
The four links states are:
1. a:link - a normal, unvisited link
2. a:visited - a link the user has visited
3. a:hover - a link when the user mouse over it
4. a:active - a link the moment it is clicked
a:link{
color:#FF0000; /*unvisited link*/
}
a:visited{
text-decoration : none; /*visited link*/
}
a:hover{
color:#00FF00; /*mouse over link*/
}
a:active{
color:#0000FF; /*selected link*/
}
CSS list
The CSS list properties allow you to:
Set different list item markers for ordered & unordered lists
Set an image as the list item marker
Set the position of the marker
CSS List Style Type
CSS List with Image
CSS List Position
ul{
list-style-type: circle;
list-style-type: disc;
list-style-type: square;
list-style-type: armenian;
list-style-type: cjk-ideographic;
list-style-type: decimal-leading-zero;
}
ol{
list-style-image : url(‘imgPath’);
}
ol{
list-style-position : outside;
list-style-position : inside;
CSS Layers
• CSS allows you to control which CSS
#division1{
item will appear on top with the use position : absolute;
of layers. height : 100px;
width : 100px;
• In CSS, each element is given a left : 100px;
priority. top : 150px;
background-color :
• If there are two overlapping CSS red;
z-index : 5;
positioned elements, the element }
with the higher priority will appear #division2{
on top of the other. HTML
position : absolute;
height : 200px;
• To manually define a id="division1">
<div priority, set the width : 200px;
left : 50px;
z-index value. The</div>
larger the value, top : 100px;
<div id="division2">
the higher the priority
</div> the element
background-color :
blue;
will have. z-index : 2;
}
CSS Float Property
The CSS float property defines that an element should be taken out of the
normal flow of the document and placed along the left or right side of its
containing block.
Text and inline elements will then wrap around this element.
CSS
#division1{
background-color : red;
HTML float : left;
width: 40%;
<div id="division1"> }
ABC Content #division2{
</div> background-color : blue;
<div id="division2"> float : right;
XYZ Content width: 40%;
</div> }
Introduction to CSS3
CSS3 is the latest standard for CSS.
CSS3 is completely compatible with earlier versions of CSS.
CSS3 has been split into "modules". It contains the "old CSS specification"
(which has been split into smaller pieces). In addition, new modules are
added.
CSS3 Transitions are a presentational effect which allow property changes
in CSS values, such as those that may be defined to occur on :hover to
occur smoothly over a specified duration – rather than happening
instantaneously as is the normal behavior.
Transition effects can be applied to a wide variety of CSS properties,
including background-color, width, height, opacity, and many more.
Introduction to CSS3 (Cont)
Some of the most important CSS3 modules are:
CSS Animations and Transitions
Calculating Values With calc()
Advanced Selectors
Generated Content and Counters
Gradients
Webfonts
Box Sizing
Border Images
Media Queries
Multiple Backgrounds
CSS Columns
Animations
CSS animations make it possible to animate transitions from one CSS style
configuration to another.
Animations consist of two components,
a style describing the CSS animation
a set of keyframes that indicate the start and end states of the animation’s style, as
well as possible intermediate waypoints.
There are three key advantages to CSS animations over traditional script-
driven animation techniques:
They’re easy to use for simple animations; you can create them without even having
to know JavaScript.
The animations run well, even under moderate system load. Simple animations can
often perform poorly in JavaScript.
Letting the browser control the animation sequence lets the browser optimize
performance and efficiency by, for example, reducing the update frequency of
animations running in tabs that aren't currently visible.
Configuring the animation
To create a CSS animation sequence, you style the element you want to
animate with the animation property. This lets you configure the timing,
duration, and other details of how the animation sequence should
progress.
Note: This does not configure the actual appearance of the animation, which is done
using the @keyframes
The sub-properties of the animation property are:
animation-name : Specifies the name of the @keyframes at-rule describing the
animation’s keyframes.
animation-duration : Configures the length of time that an animation should take
to complete one cycle.
animation-timing-function : Configures the timing of the animation; that is, how
the animation transitions through keyframes, by establishing acceleration curves.
(linear, ease, ease-in, ease-out etc…)
animation-delay : Configures the delay between the time the element is loaded
and the beginning of the animation sequence.
animation-iteration-count : Configures the number of times the animation should
repeat; you can specify infinite to repeat the animation indefinitely.
Defining the animation sequence using
keyframes
Once you’ve configured the animation’s timing, you need to define the
appearance of the animation. This is done by establishing two or more
keyframes using the @keyframes at-rule.
Each keyframe describes how the animatedCSS element should render at a
given time during
HTML the animation sequence.
p {
animation-duration: 3s;
animation-
<p>
name: slidein;
Hello World
}
</p>
div {
@keyframes slidein {
width: 100px;
from { /* or 0% */
margin-left: 100%;
height: 100px;
width: 300%;
background-color: red;
}
animation-name: example;
to { /* or 100% */
animation-duration: 4s;
margin-left: 0%;
}
width: 100%;
@keyframes example { }
from {background-color: red;} }
Tooltip
A tooltip is often used to specify extra information about something when
the user moves the mouse pointer over an element.
HTML CSS
.tooltip .tooltiptext {
<div class="tooltip">Hover here to visibility: hidden;
see tooltip width: 120px;
<span class="tooltiptext">Tooltip background-color: black;
text</span> color: #fff;
</div> text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
CSS }
.tooltip {
position: relative; .tooltip:hover .tooltiptext {
display: inline-block; visibility: visible;
border-bottom: 1px dotted black; }
}
Style Images
We can use many properties with Images like,
Opacity(The opacity property can take a value from 0.0 - 1.0. The lower value, the
more transparent)
img {
opacity: 0.5;
}
border-radius(Round image-border-radius: 8px; , circle image-border-
radius: 50%;)
img {
border-radius: 8px;
}
margimax-width to be 100% and height to be auto (to make it responsive)
img {
max-width: 100%;
height: auto;
margin-left, margin-right to be auto and display to be block (to make it aligned
center)
img {
display: block;
Filter
.blur{filter: blur(4px);}
.brightness {filter: brightness(250%);}
.contrast {filter: contrast(180%);}
.grayscale {filter: grayscale(100%);}
.huerotate {filter: hue-rotate(180deg);}
.invert {filter: invert(100%);}
.opacity {filter: opacity(50%);}
.saturate {filter: saturate(7);}
.sepia {filter: sepia(100%);}
.shadow {filter: drop-shadow(8px 8px 10px green);}
CSS Variables / Custom Properties
Custom properties (sometimes referred to as CSS variables or cascading
variables) are entities defined by CSS authors that contain specific values
to be reused throughout a document.
Advantages of using CSS variables are:
makes the code easier to read (more understandable)
makes it much easier to change.
CSS variables can have a global or local scope.
Global variables can be accessed/used through the entire document.
To create a variable with global scope, declare it inside the :root selector. The :root selector
matches the document's root element.
local variables can be used only inside the selector where it is declared.
To create a variable with local scope, declare it inside the selector that is going to use it.
We can use var() function in order to access the variable set in the css.
A good way to use CSS variables is when it comes to the colors of your
design. Instead of copy and paste the same colors over and over again,
you can place them in variables.
CSS Variables / Custom Properties
First of all: CSS variables can have a global or local scope.
Global variables can be accessed/used through the entire document, while
local variables can be used only inside the selector where it is declared.
To create a variable with global scope, declare it inside the :root selector.
The :root selector matches the document's root element.
To create a variable with local scope, declare it inside the selector that is
going to use it.
The following example is equal to the example above, but here we use
the var() function.
First, we declare two global variables (--blue and --white). Then, we use
the var() function to insert the value of the variables later in the style
sheet:
The variable name must begin with two dashes (--) and it is case
sensitive!
CSS Variables (Example)
HTML CSS
:root{
<p> --myFavColor : orange;
Hello World --myNextFacColor : green;
</p> }
<div> p{
How are you? background-color: var(--myFavColor);
</div> color: var(--myNextFacColor);
}
div{
background-color: var(--
myNextFacColor);
color: var(--myFavColor);
}
Media Queries
Media queries are a way to target browser by certain characteristics,
features, and user preferences, then apply styles based on those things.
Perhaps the most common media queries in the world are those that
target particular viewport ranges and apply custom styles.
General syntax for the media queries in CSS is,
Syntax
@media [media-type] ([media-feature]) {
/* Styles! */
}
It consists of:
A media type, which tells the browser what kind of media this code is for (e.g.
all,print, screen etc…).
A media feature, which is a rule, or test that must be passed for the contained CSS
to be applied.
A set of CSS rules that will be applied if the test passes and the media type is
correct.
Media Query (Cont.)
Media Types:
All(Used for all media type devices)
Print(Used for print preview mode)
Screen(Used for computer screens, tablets, smart-phones etc).
speech
Media Features:
width & height(Height of the viewport, Width of the viewport)
min-width, min-height, max-width & max-height
Orientation(Orientation of the viewport, Landscape or portrait)
<!DOCTYPE html><html><head>
<style>
body {
background-color: pink;}
@media screen and (min-width: 1200px) {||breakpoint
body {
background-color: lightgreen;
}}
</style></head><body>
<h1>Resize the browser window to see the effect!</h1>
<p>The media query will only apply if the media type is screen and the
viewport is 480px wide or wider.</p></body>
Media Query (Example)
<!DOCTYPE html><html><head>
<style>body {
background-color: pink;
font-size:100px;}
@media screen and (max-width: 1200px) {
body {background-color: lightgreen;
font-size:100px; }}
@media screen and (max-width: 1000px) {
body {background-color: red;font-size:75px;}}
@media screen and (max-width: 700px) {
body {
background-color: blue;
font-size:50px; }}
@media screen and (max-width: 500px) {body {
background-color: yellow;
font-size:25px; }}
</style></head><body>
<h1>Resize the browser window to see the effect!
</h1>
<p>The media query will only apply if the media
type is screen and the viewport is 480px wide or
Media Query (cont.)
We can also use and/or logic in media query, for example
We can use and as a separator if we want two condition to satisfy before applying
the CSS. CSS
@media screen and (min-width: 600px) and (max-width: 900px) {
body {
color: blue;
}
}
direction:
to bottom
to top
to right
to left
to bottom left
180deg
Etc…
Linear Gradients (Example)
Example:
CSS
background-image: linear-gradient(red, yellow);
Output:
background-image: linear-gradient(to right, red , yellow);
background-image: linear-gradient(angle, color-stop1, color-stop2);
shape:
Ellipse (defalt)
Circle
size:
farthest-corner (default)
closest-corner
farthest-side
closest-side
position:
Center (default)
Etc…
Radial Gradients (Example)
Example:
CSS
background-image: radial-gradient(red, green, yellow);
Output:
<!DOCTYPE html><head>
<style>
#grad1 {
height: 150px;
width: 200px;
background-color: red; /* For browsers that do not support gradients */
background-image: radial-gradient(red 5%, yellow 15%, green 60%);}
</style></head><body>
<h1>Radial Gradient - Differently Spaced Color Stops</h1>
<div id="grad1"></div></body>
</html>
Pseudo Classes
A pseudo-class is used to define a special state of an element.
For example, it can be used to: Syntax
Style an element when a user mouse over it selector:pseudo-class {
Style visited and unvisited links differently property: value;
Style an element when it gets focus }
Some important pseudo classes are:
active
disabled
first-child
nth-child()
focus
hover
visited
<html><head><style>
div {
background-color: green;
color: white;
padding: 25px;
text-align: center;}
div:hover {
background-color: blue;}</style></head><body>
<p>Mouse over the div element below to change its background color:</p>
<div>Mouse Over Me</div>
<!DOCTYPE html><html><head>
<style>
p:first-child {
color: blue;}
</style></head>
<body>
<p>This is some text.</p>
<p>This is some text.</p>
<div>
<p>This is some text.</p>
<p>This is some text.</p>
</div></body></html>
Pseudo Elements
A CSS pseudo-element is used to style specified parts of an element.
For example, it can be used to: Syntax
Style the first letter, or line, of an element selector::pseudo-element {
Insert content before, or after, the content of an element
property: value;
pseudo elements are, }
after(we can add text as well as image)
before
first-letter
first-line
selection
<!DOCTYPE html><html><head><style>
p::first-line {
color: #ff0000;
font-variant: small-caps;}
</style></head><body>
</body>
</html>
<!DOCTYPE html><html><head>
<style>
::selection {
color: red;
background: yellow;}
</style></head><body>
<h1>Select some text on this page:</h1>
<p>This is a paragraph.</p>
<div>This is some text in a div element.</div>
</body>
</html>
Bootstrap
Bootstrap is Free front-end framework made of HTML, CSS and
JavaScript Plugins (optional) for developing Responsive Websites.
Responsive websites means websites which Automatically Adjust
themselves to look good on all devices like mobile, desktop,laptop,tablet
etc…
Why to Use Bootstrap?
Easy to use
Anybody with just basic knowledge of HTML and CSS can start using Bootstrap
Responsive features
It's responsive CSS adjusts to phones, tablets, and desktops
Mobile-first approach
Mobile-first styles are part of the core framework
Browser compatibility
Compatible with all modern browsers (Chrome, Firefox, Internet Explorer, Safari, and Opera)
Free
Responsive Web Design
Responsive web design makes your web page look good on all devices.
Responsive web design uses only HTML and CSS.
Responsive web design is not a program or a JavaScript.
Designing For The Best Experience For All Users
Web pages can be viewed using many different devices: desktops, tablets,
and phones. Your web page should look good, and be easy to use,
regardless of the device.
Web pages should not leave out information to fit smaller devices, but
rather adapt its content to fit any device:
It is called responsive web design when you use CSS and HTML to resize,
hide, shrink, enlarge, or move the content to make it look good on any
screen.
What is The Viewport?