HTML Cheat Bca
HTML Cheat Bca
• It is the protocol used to transfer web pages • Can use tools or CMS (like WordPress) to publish
between servers and clients (browsers). text, images, and other media online.
• It is the address of a resource on the Internet. • Uses tags (like <h1>, <p>, <a>) to define elements
Example: https://www.example.com/index.html. (headings, paragraphs, links).
• Structure: protocol://domain/path (e.g., https:// is 12. What is the use of the <title> tag?
protocol, example.com is domain, /index.html is
• The <title> tag defines the title of the HTML
path).
document.
6. Define web caching.
• It appears in the browser’s title bar or tab.
• Web caching stores copies of web resources
• Important for SEO: search engines use it as the
(pages, images) to speed up access.
page title.
• Browsers and servers save files so repeated
13. Write the structure of a basic HTML document.
requests load faster and use less bandwidth.
A basic HTML document includes a doctype, <html>,
• If a page hasn't changed, the cache can serve the
<head>, and <body> tags:
stored copy instead of downloading again.
<!DOCTYPE html>
7. What is WWW?
<html>
<head> • Examples include:
15. Write the difference between <ol> and <ul>. • Example: <hr> adds a thin horizontal line across
the page.
• <ol> creates an ordered list (numbered items).
20. Name any two heading tags in HTML.
• <ul> creates an unordered list (bulleted items).
• Two heading tags are <h1> and <h2>.
Example:
• There are six levels: <h1> (largest) through <h6>
<ol> (smallest).
<li>First item</li> • Example:
<li>Second item</li> • <h1>Main Title</h1>
</ol> • <h2>Subheading</h2>
<ul> 21. What is the purpose of the <table> tag?
<li>Apple</li> • The <table> tag is used to create tabular data
<li>Banana</li> (rows and columns).
</ul> • It contains <tr> for table rows, <td> for cells, and
<th> for header cells.
16. What is an anchor tag?
• Example:
• The <a> tag defines a hyperlink (anchor).
• <table>
• It uses the href attribute to link to another URL.
• <tr><th>Name</th><th>Age</th></tr>
• Example:
• <tr><td>Alice</td><td>30</td></tr>
• <a href="https://www.example.com">Visit
Example</a> • </table>
17. What are empty tags? Give examples. 22. What does <th> represent in a table?
• Empty tags (self-closing) have no closing tag or • <th> stands for table header cell.
content.
• It defines a header cell in a table row. By default, • Radio Button (<input type="radio">): Allows
its content is bold and centered. selection of one option within a group. Radios with
the same name are linked.
• Example:
• Checkbox (<input type="checkbox">): Allows
• <table>
multiple independent selections. Each checkbox
• <tr><th>Name</th><th>Age</th></tr> is separate.
• <tr><td>Bob</td><td>25</td></tr> • Example:
• Can cause SEO issues and complicate page • ID Selector (#): Targets an element by its unique
layout. id. Each page element can have only one ID.
• Modern web design uses CSS and modern layout • Class Selector (.): Targets one or more elements
techniques instead. by a shared class. Multiple elements can share the
same class.
30. Write the syntax of <frameset>.
• Example:
• <frameset> was used to define a frames-based
layout (replacing <body>). • <div id="header">...</div>
• Inline CSS applies styles directly in an HTML tag’s • Used for responsive design.
style attribute.
• Syntax example:
• Example:
• @media screen and (max-width: 600px) {
• <p style="color: red; font-size: 14px;">This is red
• /* CSS rules for small screens */
text.</p>
• body { background-color: lightgreen; }
• It only affects that specific element.
• }
38. Define the box model. • Event-Driven: Easily responds to events like clicks
or keystrokes.
• The CSS box model describes layout of elements.
• (Other features: Client-side execution, object-
• It has four parts:
oriented, interpreted language, cross-platform.)
o Content: The actual content (text, images).
43. Name different data types in JavaScript.
o Padding: Space between content and
• Number: e.g., 42, 3.14.
border.
• String: text, e.g., "Hello".
o Border: Edge around padding.
• Boolean: true or false.
o Margin: Space outside the border.
• Object: Collections of key/value pairs (includes
• Example visualization:
arrays and functions).
• [ margin ] -> [ border ] -> [ padding ] -> [ content ]
• Null: represents no value.
39. What is the use of z-index?
• Undefined: variable declared but not assigned.
• z-index sets the stacking order of positioned
• Symbol: unique identifier.
elements along the z-axis (depth).
• BigInt: for very large integers (beyond Number
• Higher z-index means the element is on top of
range).
those with lower z-index.
44. How is JavaScript added to HTML?
• It only works on elements with position (e.g.,
relative, absolute). • Use the <script> tag.
• .modal { position: absolute; z-index: 10; } o External: Link an external .js file.
• JavaScript (JS) is a scripting language for the web. • Constant: A named container whose value cannot
be changed once set. Declared with const.
• It runs in the browser (and also on servers with Example: const PI = 3.14;
Node.js) to make web pages interactive and
dynamic. 46. Name any two operators in JavaScript.
• Example use: updating content without reloading, • Arithmetic operators: +, -, *, /, % (used for math).
responding to user actions (clicks, forms). • Comparison operators: ==, ===, !=, >, <, <=, >=
42. List any two features of JavaScript. (used to compare values).
• Dynamic Typing: Variables can hold any type • (Other examples: assignment =, logical &&, ||, etc.)
(string, number, etc.) without declaring a type. 47. What is the use of if statement?
• The if statement is used for conditional • A for loop repeats code a specific number of
execution. times.
• Example:
• function greet(name) {
• }
• Example:
• <script>
• document.getElementById("myBtn").onclick = function() {
• alert("Button clicked!");
• };
• </script>