UNIT-1-HTML_CSS
UNIT-1-HTML_CSS
3CSE-B
2024-25
Prepared BY
Dr.M.Gangappa
Examples:
Examples of elements of
structure of a document head body p
Examples of elements as
<head> <body> <p>
tags
A start tag instructs the browser to start a particular instruction. Conversely, an end tag marks the end of that
instruction.
Typically a complete web page contains many tags and sometimes nested tags (tags within other tags), it is necessary to
close all opened tags .
Main points to remember:
1. Every element has a name such as head, title, p, i, and b.
2. A tag is the element name surrounded by the angled brackets. This refers to a start tag such as <p>, <title>, and
<i>
3. Most elements have content, which is placed between the start and the end tags. Example, this is
<b>bold</b>.
4. Some elements have no content. Such elements/tags are known as empty tags.
5. Empty elements do not have end tags.
21-02-2025 Prepared By Dr.M.Gangappa, VNR VJIET 10
Understanding attributes
In HTML, elements (or tags) have attributes or properties. The attributes allow you to add extra instruction to your
tags.
An attribute has two parts:
1. attribute name
2. attribute value.
Example 1:
align="right" is an example of attribute-value pair. The word align is the attribute. The value of this attribute
is right.
Example 2:
<p align="right">This is my paragraph. Normally, text and other object on a web page are left-aligned. Because this
paragraph has an extra instruction (align="right") to start this particular paragraph from the right, the paragraph is
right-aligned.</p>
Syntax :
<p [ align = “left”|”center”|”right”] > … </p>
3. Creating headings
Syntax:
<h1 [ align = “left”|”center”|”right”] > … </h1>
<h2 [ align = “left”|”center”|”right”] > … </h2>
<h3 [ align = “left”|”center”|”right”] > … </h3>
<h4 [ align = “left”|”center”|”right”] > … </h4>
<h5 [ align = “left”|”center”|”right”] > … </h5>
<h6 [ align = “left”|”center”|”right”] > … </h6>
Syntax:
<a href = “URL” title=“title of the link” target = “value”> … </a>
program
21-02-2025 Prepared By Dr.M.Gangappa, VNR VJIET 16
Lists
Lists are used to group together related pieces of information so they are clearly
associated with each other and easy to read.
List types
There are three list types in HTML:
➢ unordered list — used to group a set of related items in no particular order
➢ ordered list — used to group a set of related items in a specific order
➢ definition list — used to display name/value pairs such as terms and definitions
Image as a link
Example2:
The three elements for separating the head, body, and foot of a
table are −
Example:
https://html.com/frames/
Named Frames
Example 2: Example4:
END of HTML
.hometown {
background: yellow; }
</body>
</html>
Dr.M.Gangappa,Department of Computer Science &
February 21, 2025 51
Engineering, VNRVJIET, Hyderabad
Inline CSS
➢ We can write CSS inside of an HTML tag, using the style attribute.
➢ When CSS is written using the style attribute , it is called an “inline style
sheet”.
INLINE STYLE SYNTAX :
</body>
</html>
<span> tag
HTML <span> tag is used as a generic container of inline elements.
Demo
Dr.M.Gangappa,Department of Computer Science &
February 21, 2025 61
Engineering, VNRVJIET, Hyderabad
CSS UNITS
CSS has several different units for expressing a length. There are two types of
length units: absolute and relative.
Absolute units
Unit Description
cm centimeters
mm millimeters
in inches (1in = 96px = 2.54cm)
px pixels (1px = 1/96th of 1in)
pt points (1pt = 1/72 of 1in)
Dr.M.Gangappa,Department of Computer Science &
February 21, 2025 62
Engineering, VNRVJIET, Hyderabad
CSS UNITS
Relative length units specify a length relative to another length property.
Back grounds
background-color : “color name”
background-image : “url”
background-repeat : repeat-x| repeat-y |no-repeat
background-position : top right bottom left center
Dr.M.Gangappa,Department of Computer Science &
February 21, 2025 66
Engineering, VNRVJIET, Hyderabad
Box model
The “CSS box model” is a set of rules that determine the dimensions
of every element in a web page. It gives four properties for each HTML
element.
1. Content – The text, image, or other media content in the
element.
2. Padding – The space between the box’s content and its
border.
3. Border – The line between the box’s padding and margin.
4. Margin – The space between the box and surrounding
boxes.
Dr.M.Gangappa,Department of Computer Science &
February 21, 2025 67
Engineering, VNRVJIET, Hyderabad
Box model
Margin – properties
CSS has properties for specifying the margin for each side of an
element:
❑ margin-top
❑ margin-right
❑ margin-bottom
❑ margin-left
CSS has properties for specifying the padding for each side of an
element:
❑ padding-top
❑ padding-right
❑ padding-bottom
❑ padding-left
The following CSS list properties are available for usage in controlling the CSS lists:
•List-style-type:This property is used to determine the look of the list item marker, such
as a disc, character, or custom counter style.
•List-style-image: The pictures that will serve as list item markers may be specified using
this parameter.
•List-style-position: It describes where the marker box should be about the main block
box.
21-02-2025
•List-style: The list style is configured with this attribute.
Prepared By Dr.M.Gangappa, VNR VJIET 76
List-style-type property
The default list type of marker may be changed to a variety of other types, including square, circle,
Roman numerals, Latin letters, and many more. The entries in an unordered list are denoted by
round bullets (•), while the items in an ordered list are numbered by default using Arabic numerals
(1, 2, 3, etc.).
The markings or bullets will be removed if we set their value to none.
Syntax:
list-style-type:value;
Syntax
display:value;
div.static {
position: static;
border: 3px solid #73AD21;
}
position: relative;
div.relative {
position: relative;
left: 30px;
border: 3px solid #73AD21;
}
placed in front of, or behind, the others). An element can have a positive or negative
stack order:
Set the z-index for an image, so that it is displayed behind the text:
<!DOCTYPE html> <h1>The z-index Property</h1>
<html>
<head> <img src="w3css.gif" width="100" height="140">
<style>
img { <p>Because the image has a z-index of -1, it will be placed behind the
position: absolute; text.</p>
left: 0px;
top: 0px; </body>
z-index: -1; </html>
}
</style>
</head>
<body> 21-02-2025 Prepared By Dr.M.Gangappa, VNR VJIET 85
CSS Layout: OVERFLOW
The CSS overflow property controls what happens to content that is too big to fit into an
area.
❑ visible - Default. The overflow is not clipped. The content renders outside the element's
box
❑ hidden - The overflow is clipped, and the rest of the content will be invisible
❑ scroll - The overflow is clipped, and a scrollbar is added to see the rest of the content
❑ auto - Similar to scroll, but it adds scrollbars only when necessary
Also, with display: inline-block, the top and bottom margins/paddings are respected, but
with display: inline they are not.
Compared to display: block, the major difference is that display: inline-block does not add
a line-break after the element, so the element can sit next to other elements.
li {
display: inline;
}
a {
display: block;
padding: 8px;
background-color: #dddddd;
21-02-2025 Prepared By Dr.M.Gangappa, VNR VJIET 89
}
CSS Dropdowns
Basic Dropdown
Create a dropdown box that appears when the user moves the mouse over an element.
Dropdown Menu
Create a dropdown menu that allows the user to choose an option from a list: