HTML Css Note
HTML Css Note
HTML&CSS
The Internet
The Internet, the interconnected network of computer networks that spans the globe,
seems to be everywhere today.
Birth of the Internet- the Internet began as a network to connect computers at research
facilities and universities.
Birth of the Web- Development of the World Wide Web by Tim Berners-Lee at
CERN
Development of Mosaic, the first graphics-based web browsers at NCSA.
Intranet
A private network contained within an organization or business used to share information
and resources among coworkers.
Extranet
A private network that securely shares part of an organization’s information or operations
with external partners.
Network
Consists of two or more computers connected for the purpose of communicating and
sharing resources.
Types of Network
Local Area Network (LAN)
It is usually confined to a single building or group of connected buildings
Client/Server Model
Client (Web Browser)
requests some type of service (such as a file or database access) from the server
Email Protocols
Sending E-mail
SMTP Simple Mail Transfer Protocol
Receiving E-mail
POP (POP3) Post Office Protocol
IMAP Internet Mail Access Protocol
IDE
Notepad
Visual Studio Code
Notepad++
Dream Weaver etc…
<body>
…..body text and more HTML5 tags go here…
</body>
</html>
meta charset=”utf-8”
The meta element descripts a character of a web page
Character encoding is the internal representation of letter, numbers, and symbols in a
file
HTML5 meta Tag
HTML Tags
Heading Tag
Organize into six levels: h1 through h6
h1 is the largest size of text
The smallest for h6
Display with bold font weight
Change the location use align attribute with values (left/center/right/justify)
Example
<h1 align=”center”>
Heading</h1>
Paragraph Tag
Display paragraph using <p> tag
Display left side each paragraph
Change the paragraph position uses align attribute with values (left/ right/ center /
justify)
Example
<p>This is a sample paragraph. Heading tags can help to make your pages more
accessible and usable. It is good coding practice to use heading tags to outline the
structure of your web page content.</p>
(or)
<p align=”center”>This is a sample paragraph. </p>
Underline Tag
Display text with underline use <u> tag
Example
<u>Hello </u> Hello
Superscript Tag
Display the math formula with super use <sup>
Example
x<sup>2</sup> x2
Subscript Tag
Display the math formula with subscript <sub>
Example
H<sub>2</sub>O H2O
Strikethrough Tag
Display the text with strikethrough use <strike>
Example
<strike>Strike Tag </strike> Strike Tag
Lists
Unordered List
displays a bullet or list marker
can be one of three types: disc (the default, square and circle)
<html lang="en">
<head>
<meta chaset="UTF-8">
<title>Example of Lists</title>
</head>
<body>
<h3>The following is Ordered list</h3>
<ol type="I">
<li>HTML5</li>
<li>CSS</li>
<li>JavaScript</li>
</ol>
<h3>The following is Unordered List</h3>
<ul type="square">
<li>PHP</li>
<li>Java</li>
<ol type="i">
<li>J2SE</li>
<li>J2EE</li>
<li>J2ME</li>
</ol>
<li>Python</li>
</ul>
<h3>The following is definition list.</h3>
<dl>
<dt>Website</dt>
<dd>A location connected to the Internet
that maintain one or more pages on the World
Wide We.</dd>
</dl>
</body>
</html>
Highlight Tag
Display the text with highlight use <mark> tag
Example
<p>Phrase element is also called <mark> inline </mark> </p>
Special Characters
use in your web page document, you need to use special characters
called entity character
Character Entity Name Code
Image Tag
Department of Information Technology Supporting and Maintenance Page 10
Web Development Technology (HTML+CSS)
Marquee Tag
creating scrollable text or images within a web page use <marquee> tag
direction- provides the direction or way in which your marquee will allow you to
scroll. The value of this attribute can be: left, right, up or down
scrollamount- provides value for speeding the marquee feature
bgcolor- provides a background color where the value will be either the name of the
color or the hexadecimal color-code.
Example
<marquee direction=”up” scrollamount=10> Welcome to My Page </marquee>
Video Tag
insert a video in a web page use <video> tag
sourceused for inserting video
controlsvideo controls should be displayed such as a play/pause button
typevideo format
Example
<video width="320" height="240" controls>
<source src="videoplayback (4).mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
Audio Tag
insert a audio in a web page use <audio> tag
sourceused for inserting video
controlsaudio controls should be displayed such as a play/pause button
typeaudio format (mp3mpeg, oggogg)
Example
Department of Information Technology Supporting and Maintenance Page 11
Web Development Technology (HTML+CSS)
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="songs/song1.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
Table Tag
to create a table use <table> tag
define the row use <tr> tag
define the col use <td> tag or <th> tag
use <th> tag display text with bold and center
<caption> tag displays table caption
width, heightdefine table, row and col width and height
borderdefine table border
colspandefine merge column
rowspandefine merge row
aligndefine cell direction change horizontal (left (default), right, center)
valign define cell direction change vertical (middle(default), top, bottom)
cellpaddingSpecifies the space between the cell content and its border
cellspacingBorder spacing specifies the space between the cells
Example 1
<table border="1" width="200px">
<caption>Student Lists</caption>
<tr>
<th >Name</th>
<th>Phone Number</th>
</tr>
<Tr>
<td>Su Su</td>
<td>098744</td>
</Tr>
<Tr>
<td>Mya Mya</td>
<td>78995</td>
</Tr>
<Tr>
<td>Zaw Zaw </td>
<td>098744</td>
</Tr>
<Tr>
<td>Aung Aung</td>
<td>098744</td>
</Tr>
</table>
Form Elements
Use forms to help with a variety of functions, including accepting visitor feedback,
encouraging visitors to send a news story to a friend or colleague, collecting e-mail
addresses for a newsletter, and accepting order information
Introduces a very powerful tool for web developers- forms that accept information
from web page visitors
Syntax: <form>…………… </form>
1. Text Box Control
accepts text or numeric information such as names, e-mail addresses, phone numbers,
and other text
typedefine the form control (text)
namedefine the text box name
sizetextbox size
maxlengthdefine the maximum length of the characters in text box
Figure 16: The <input> tag with type=“text” configures this form element
<!DOCTYPE html>
<html>
<head>
<title>Check Box Example</title>
</head>
<body>
<h2>Sample Check Box</h2>
<form>Choose the browsers you use:<br>
<input type="checkbox" name="IE" id="IE" value="yes">Internet
Explorer<br>
<input type="checkbox" name="Firefox" id="Firefox" value="yes">Firefox<br>
<input type="checkbox" name="Oprea" id="Oprea" value="yes">Opera
<br></form></body></html>
option tag
o valueget select box control each element value
o selectedchose the selected element in select box control
Example
<!DOCTYPE html>
<html>
<head><title>Select List</title>
</head><body>
<h2>Select List: One Initial Visible Item</h2>
<form>
<select size="1" name="favbrower" id="favbrower">
<option>Select your favorite browser</option>
<option value="Internet Explorer">Internet Explorer</option>
<option value="Firefox">Firefox</option>
<option value="Opera">Opera</option>
</select>
</form>
</body>
</html>
Example
<fieldset>
<legend>Billing Address</legend>
<label>Street: <input type="text" name="street" id="street" size="54">
</label><br><br>
<label>City: <input type="text" name="city" id="city"> </label>
<label>State: <input type="text" name="state" id="state" size="5"
maxlength="2"></label>
<label>Zip: <input type="text" name="zip" id="zip" size="5" maxlength="2"></label>
</fieldset>
Figure 25: Form controls that are all related to a mailing address
<h1>Choose A Number</h1>
<label for="myChoice">Choose a number between 1 and 100:</label><br>Low
<input type="range" name="myChoice" id="myChoice"> High<br><br>
<input id="mySubmit" type="submit" value="Send">
<input id="Reset" type="Reset" value="Reset">
Favorites Icon
The favorites icon - a favicon, a square image (either 16x16 pixels or 32x32 pixels)
associated with a web page.
<link rel=“icon” href=“favicon.ico” type=“image/x-icon”>
Imported Styles
Similar to external styles
Using the @import directive
<meta charset="utf-8">
<style>
body { backgrond-color:#ccffff;
color: #000033; }
</style>
</head>
<body>
<h1>Embedded CSS</h1>
<p>This page uses embedded styles.</p>
</body>
</html>
site.css
Place a dot (.) in front of the class name in the style sheet
CSS:
.feature { color: #ff0000;}
HTML
<li class=“feature”>Usability Studies</li>
“class” is an html attribute
Example
<html>
<head>
<title> Example of Class Selector </title>
<style>
.feature { color: #ff0000;}
</style>
</head>
<body>
<ul>
<li>E-Commerce Solutions</li>
<li class=“feature”>Usability Studies</li>
<li class=“feature”>Search Engine</li>
</ul>
</body>
</html>
</div>
“id” is an html attribute
Example
<html>
<head>
<title> Example of id Selector </title>
<style>
#footer { color: #ff0000;
font-size: .75em;
font-style: italic;}
</style>
</head>
<body>
<div id=“footer”>
Copyright © 2012 Ma Ma
</div>
</body>
</html>
Contextual Selector
Refer to as descendent selectors
Specify an element within the context of its container(parent) element
List the container selector followed by the specific selector
Advantages: reduce the number of classes and ids
Example: div p { color: #ff0000;}
</style>
</head>
<body>
<div>
<p> This is a paragraph inside a div element</p>
<p> This is a another paragraph inside a div element</p>
</div>
<p> This is a paragraph, not inside a div element.</p>
</body>
</html>
</html>
To change the style of the bottom, left, top, and right borders of an element
individually using the following properties −
border-bottom-style
border-top-style
border-left-style
border-right-style
Example
.dotted {border-style: dotted;}
.dashed {border-style: dashed;}
.solid {border-top-style: solid;}
.double {border-right-style: double;}
.groove {border-bottom-style: groove;}
.ridge {border-left-style: ridge;}
.inset {border-style: inset;}
.outset {border-style: outset;}
.none {border-style: none;}
.hidden {border-style: hidden;}
.mix {border-style: dotted dashed solid
double;}
padding-left
Background Images
configure a background image
body { background-image: url(texturel.png); }
background-color
body { background-color: #99cccc;background-image: url(background.jpg); }
The background-repeat property sets if/how a background image will be repeated. It
include repeat (default), repeat-y (vertical repeat), repeat-x (horizontal repeat) and no-
repeat (no repeat).
#example1 {
padding: 25px;
background: url(trilliumsolo.jpg);
background-repeat: no-repeat;
background-origin: padding-box;
padding: 25px;
background: url(myislandback.jpg);
background-repeat: no-repeat;
background-size: auto;
padding: 10px;
border-radius: 25px; }
Example
text-shadow: 5px 5px 5px #828282;
Opacity Property
opacity property – configures the transparency of the background color.
Opacity value range from 0 (completely transparent) to 1 (no transparency).
Position Property
The position property specifies the type of positioning method used for an element (static,
relative, fixed, absolute or sticky).
1. Relative Position
The position property specifies the type of positioning method used for an element.
The values are static, relative, fixed, absolute and sticky.
Use relative positioning to change the location of an element slightly, relative to
where it would otherwise appear with normal flow.
Left - Right
Top - Bottom
Example
<!DOCTYPE html>
<html lang="en">
<head><title>Relative positioning</title>
<meta charset="utf-8">
<style>
#myContent { position: relative;left:30px;font-family: Arial, sans-serif; }
h1 { background-color: #cccccc;padding: 5px;color:#000000; }
</style></head><body>
<h1>Relative Positioning</h1><div id="myContent">
<p> This paragraph uses CSS relative positioning to be placed 30 pixels in from the left
side.</p></div>
</body></html>
Overflow Property
This property specifies whether to clip content or to add scrollbars when an element’s
content is too big to fit in a specified area.
The overflow property specifies what should happen if content overflows on element
box.
The overflow property only works for block elements with a specified height.
Overflow property of value is visible, hidden, scroll and auto.
CSS interactivity Pseudo-Classes
Example
a:hover
{
color: #ff0000;
}
Basic Two Column Page Layout
A common design for a web page is a two-column layout. This can be accomplished
with CSS by configuring one of the columns to float on the web page.
Hands on Practice 1
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;margin: 0;padding: 0;overflow: hidden;background-color: #333;
}
li {
float: left;}
li a, .dropbtn {
display: inline-block;color: white;text-align: center;padding: 14px 16px;
text-decoration:none;
}
li a:hover, .dropdown:hover .dropbtn {
background-color: red;
}
.dropdown-content {
display: none;position: absolute;background-color: #f9f9f9; min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
.dropdown-content a {
color: black;padding: 12px 16px;text-decoration: none;display: block; text-align: left;
}
.dropdown-content a:hover {background-color: #f1f1f1;}
.dropdown:hover .dropdown-content {
display: block;
}
</style>
</head>
<body>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
Department of Information Technology Supporting and Maintenance Page 43
Web Development Technology (HTML+CSS)
<li class="dropdown">
<a href="#" class="dropbtn">Dropdown</a>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</li>
</ul>
<h3>Dropdown Menu inside a Navigation Bar</h3>
<p>Hover over the "Dropdown" link to see the dropdown menu.</p>
</body></html>
.header {
background-color: #f1f1f1;padding: 10px;text-align: center;
}
.topnav { overflow: hidden;background-color: #333;
}
.topnav a {
display: inline-block;color: #f2f2f2;text-align: center; padding: 14px 16px;
text-decoration: none;
}
.topnav a:hover {
background-color: #ddd;color: black;
}
.column {
float: left;padding: 10px;
}
.column.side {
width: 25%;
}
.column.middle {
width: 50%;
}
.row::after {
content: ""; display: table; clear: both;
}
@media screen and (max-width: 600px) {
.column.side, .column.middle {
width: 100%;
}
}
.footer p {
background-color: #f1f1f1;padding: 5px; text-align: center;
}
p{
text-align: justify;
Department of Information Technology Supporting and Maintenance Page 45
Web Development Technology (HTML+CSS)
}
.t{border-radius: 5px;border-color: blue;border-style:outset;}
.btn{border-radius: 5px;background-color: blueviolet;color: wheat;line-height:25px ;}
</style>
</head>
<body>
<div class="header">
<h1>Web Development Technology HTML + CSS</h1>
</div>
<div class="topnav">
<a href="#">Home</a>
<a href="#">Registration</a>
<a href="#" class="dropbtn">Course
</a>
</div>
<div class="row">
<div class="column side">
<h2>Course</h2>
<p>
<ul>
<li>HTML & CSS</li>
<li>PHP</li>
<li>J2SE</li>
<li>J2EE</li>
</ul>
</p>
</div>
one web element from another. Using HTML & CSS, you can design rudimentary web pages
and begin the process of learning how to create dynamic and evocative web pages.
</p>
<p>
Using HTML & CSS, you can design web pages and begin the process of learning
how to create dynamic and static web pages.
</p>
</div>
<div class="column side">
<table>
<caption><h2>Registration</h2></caption>
<tr>
<td>Name</td>
</tr>
<tr>
<td class="t"><input type="text" size="20" placeholder="Enter Name.."></td>
</tr>
<tr>
<td>Phone Number</td>
</tr>
<tr>
<td class="t"><input type="text" size="20" placeholder="Enter Phone Number
.."></td>
</tr>
<tr>
<td>Attend course</td>
</tr>
<tr>
<td>
<select>
<option>HTML & CSS</option>
<option>JavaScript</option>
<option>PHP</option>
</select>
Department of Information Technology Supporting and Maintenance Page 47
Web Development Technology (HTML+CSS)
</td>
</tr>
<tr>
<td>Pay Fees</td>
</tr>
<tr>
<td>
<input type="radio" name="rdo" checked>Kpay
<input type="radio" name="rdo">Wave
</td>
</tr>
<tr>
<td align="center">
<input type="button" value="Register" class="btn">
</td>
</tr>
</table>
</div>
</div>
<div class="footer">
<p>Department of Information Technology Suppporting and Maintenance </p>
</div>
</body>
</html>