ASSIGNMENT - Webdevelopment Basics
ASSIGNMENT - Webdevelopment Basics
ASSIGNMENT -2 WAD
________________________________________________________________
__________________
1. How do you apply CSS to an HTML document?
CSS (Cascading Style Sheets) to an HTML document can be done in several
ways:
1. Inline CSS: directly add CSS to HTML elements using the style attribute. This
method is useful for small changes.
<p style="color: blue; font-size: 20px;">This is a paragraph.</p>
2. Internal CSS:include CSS within the <style> tag inside the <head> section of
your HTML document. This is suitable for a single-page styling.
<style>
p {color: blue; font-size: 20px; }
</style>
</head>
3. External CSS: create a separate CSS file (e.g., styles.css) and link it to your
HTML document using the <link> tag. This is the preferred method for larger
websites.
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
open)
JavaScript
6. Explain the role of <canvas> and <svg> elements in creating graphical
content in HTML5.
The <canvas> element provides a bitmap-based drawing surface that allows for
dynamic rendering of 2D and 3D graphics using JavaScript.
Features:
• Uses JavaScript to draw shapes, lines, and images.
• Best for real-time animations, game graphics, and visual effects.
• Graphics are raster-based, meaning they are drawn as pixels and cannot be
resized
without losing quality.
• Once drawn, elements cannot be individually manipulated.
Example:
<canvas id="myCanvas" width="200" height="100"></canvas>
The <svg> element is used to create scalable vector graphics, which means the
graphics are defined using XML and do not lose quality when resized.
Features:
• Uses XML syntax to define shapes and images.
• Best for charts, icons, maps, and illustrations.
• Graphics are vector-based, meaning they scale without losing clarity.
• Individual elements can be manipulated using CSS and JavaScript.
Example:
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" fill="blue" />
</svg>
7. Compare DTD and XML Schema, highlighting their roles in defining XML
document structure and validation.
• DTD (Document Type Definition): Defines the structure and rules for an XML
document using a simple, non-XML syntax.
• XML Schema (XSD - XML Schema Definition): Defines the structure, data
types, and
constraints of an XML document using XML syntax.
9. Briefly define DOM and discuss its role in accessing and manipulating
HTML
and CSS dynamically.
The DOM (Document Object Model) is a programming interface for web
documents. It represents an HTML or XML document as a tree structure where
each element, attribute, and piece of text is a node. JavaScript can interact with
the
DOM to dynamically access and modify the document’s content, structure, and
styling.
Role of DOM in Accessing and Manipulating HTML and CSS Dynamically:
• Accessing HTML Elements The DOM allows JavaScript to find elements using
methods like getElementById(), querySelector(), etc.
• Modifying Content The text, attributes, and structure of elements can be
changed
dynamically.
• Manipulating CSS Styles JavaScript can modify an element’s styles
dynamically.
• Handling Events The DOM allows adding event listeners to elements for
interactivity.
• Adding and Removing Elements The DOM lets JavaScript create and delete
elements
dynamically.