web technology unit 3
web technology unit 3
DHTML stands for Dynamic Hypertext Markup language i.e., Dynamic HTML.
Dynamic HTML is not a markup or programming language but it is a term that combines the
features of various web development technologies for creating the web pages dynamic and
interactive.
HTML 4.0:
HTML is a client-side markup language, which is a core component of the DHTML. It defines the
structure of a web page with various defined basic elements or tags.
CSS:
CSS stands for Cascading Style Sheet, which allows the web users or developers for controlling the style
and layout of the HTML elements on the web pages.
JavaScript:
JavaScript is a scripting language which is done on a client-side. The statements in JavaScript are the
commands which tell the browser for performing an action.
DOM:
DOM is the document object model. It is a w3c standard, which is a standard interface of programming
for HTML. It is mainly used for defining the objects and properties of all elements in HTML.
Uses of DHTML:
It is used for designing the animated and interactive web pages that are developed in real-time.
DHTML helps users by animating the text and images in their documents.
It also allows the page authors for including the drop-down menus or rollover buttons.
It is also used to add the ticker on various websites, which needs to refresh their content
automatically.
Features of DHTML:
Its simplest and main feature is that we can create the web page dynamically.
Dynamic Style is a feature, that allows the users to alter the font, size, color, and content of a
webpage.
It provides the facility for using the events, methods, and properties. And, also provides the
feature of code reusability.
DHTML Events:
Example of events:
1. Click a button.
2. Submitting a form.
3. An image loading or a web page loading, etc.
CSS Syntax:
Types of CSS:
1. Inline - CSS
2. Internal CSS
3. External CSS
Inline CSS :
Inline CSS involves applying styles directly to individual HTML elements using the style attribute.
This method allows for specific styling of elements within the HTML document, overriding any
external or internal styles.
When multiple styles are applied to the same element, CSS follows a specific order of
precedence to determine which style to apply. The order of precedence is:
1. Inline styles (highest priority).
2. Internal style sheet.
3. External style sheet (lowest priority).
Example:
<html>
<body>
</body>
</html>
Internal CSS:
The internal style is defined inside the <style> element, inside the head section.
It applies styles to specified HTML elements, The CSS rule set should be within the HTML file in
the head section i.e. The internal style is defined inside the <style> element, inside the head
section.
Example:
<html>
<head>
<style>
body {
background-color: blue;
color:white;
font-size:40px;
h1 {
color: yellow;
margin-left: 40px;}
</style>
</head>
<body>
<h1>Internal CSS</h1>
<p>Computer Science</p>
</body>
</html>
External CSS:
External CSS contains separate CSS files that contain only style properties with the help of tag
attributes (For example class, id, heading, … etc).
CSS property is written in a separate file with a .css extension and should be linked to the HTML
document using a link tag <link>, inside the head section.
Example:
HTML File:
<html>
<head>
</head>
<body>
</body>
</html>
body{
background-color:pink;
h1{
color:blue;
font-style:bold;
text-align:center;
p{
text-align:right;
font-style:italic;
Example:
all <p> elements on the page will be center-aligned, with a blue text color.
p{
text-align: center;
color: blue;
}
2. Based on Id:
The id selector uses the id attribute of an HTML element to select a specific element.
The id of an element is unique within a page, so the id selector is used to select one unique
element.
To select an element with a specific id, write a hash (#) character, followed by the id of the
element.
Example:
<html>
<head>
<style>
#para1 {
text-align: center;
color: red;
</style>
</head>
<body>
</body>
</html>
3.Based on Class:
The class selector selects HTML elements with a specific class attribute.
To select elements with a specific class, write a period (.) character, followed by the class name.
Example:
<html>
<head>
<style>
.center {
text-align: center;
color: red;
</style>
</head>
<body>
</body>
</html>
4.Universal selector(*):
The universal selector (*) selects all HTML elements on the page.
Example:
<html>
<head>
<style>
*{
text-align: center;
color: blue;
</style>
</head>
<body>
<h1>Hello world!</h1>
<p>And me!</p>
</body>
</html>
5.Grouping Selector:
The grouping selector selects all the HTML elements with the same style definitions.
To group selectors, separate each selector with a comma.
Example:
<html>
<head>
<style>
h1, h2, p {
text-align: center;
color: green;
</style>
</head>
<body>
<h1>Hello World!</h1>
<h2>Smaller heading!</h2>
<p>This is a paragraph.</p>
</body>
</html>
Window object − Top of the hierarchy. It is the outmost element of the object hierarchy.
Document object − Each HTML document that gets loaded into a window becomes a document object.
The document contains the contents of the page.
Form object − Everything enclosed in the <form>...</form> tags sets the form object.
Form control elements − The form object contains all the elements defined for that object such as text
fields, buttons, radio buttons, and checkboxes.
open() - Opens an output stream to collect the output from document.write() or document.writeln().
writeln() - Same as write(), but adds a newline character after each statement.
Example :
<html>
<head>
<title>
</title>
</head>
<body>
<p id="demo"> This text changes color when the page loaded. </p>
</font>
<script type="text/javascript">
document.getElementById('demo').style.color = "red";
</script>
</body>
</html>