Week 7 - Mark up Languages Flashcards

1
Q

What is a markup language?

A

A system for annotating text with computer-parseable information to define:

How text should be interpreted: Tags like <h1> indicate the text is a heading.
How it should be presented: <h1> makes the text appear larger and bold.
Relationships between text: A hyperlink tag <a> connects one text to a URL.</a>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

GET VS POST

A

GET - SAFE AND IDEMPOTENT
GET - FASTER
POST IS BETTER FOR LARGE DATA AND SECURITY
- DOESNT EXPOSE ALL SUMBITTED INFORMATION AS PART OF URL IN QUERY STRING

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the rule about hierarchy in markup languages?

A

Markup annotations must not overlap; tags should be nested properly.

Example (Proper Nesting):

<b><i>This text is bold and italic</i></b>

Example (Improper Nesting):

<b>This text is <i>bold and italic</b></i></b>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is HTML, and what is it used for?

A

HTML (Hypertext Markup Language) structures and presents content on web pages USING PREDIFINED TAGS ( IMPORTANT)

Example:

<h1>Welcome to My Website</h1>

<p>This is a paragraph of text.</p>

<a>Visit Example</a>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is XML, and how does it differ from HTML?

A

XML (Extensible Markup Language) is used to store, organize, and transfer data. Unlike HTML, XML focuses on data structure, not presentation.

Example:

<bookstore>
<book>
<title>Introduction to Programming</title>
<author>John Doe</author>
<price>29.99</price>
</book>
</bookstore>

Relation to XML’s Focus on Data Structure:
In this example, <bookstore>, <book>, <title>, and <author> are custom tags that describe the structure of the data (e.g., a bookstore catalog).</author></title></book></bookstore>

XML DOES NNOT SPECIFY HOW the DATA should be DISPLAYED (e.g., font size, color), leaving that responsibility to the application using the XML file.
Contrast with HTML:
HTML uses predefined tags like <h1> or <p> to control how content looks on a web page, focusing on presentation rather than data organization.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is hypertext, and how does it differ from linear text?

A

Hypertext is non-linear text that includes links to other text, allowing users to navigate across documents through multiple paths.
Example (HTML):

<a>Go to Chapter 2</a>
Clicking this link takes the user directly to Chapter 2, unlike linear text which must be read sequentially.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is HTML, and what is its purpose?

A

HTML (Hypertext Markup Language) is the language used to structure and present content on web pages.

It describes the structure of a web page: Elements like headings, paragraphs, and links.
It specifies how content is presented: By defining visual elements like bold text or lists.
Example:

<h1>Welcome</h1>

<p>This is my website.</p>

<a>Visit Here</a>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the basic structure of an HTML document?

A

An HTML document consists of:

Root element <html>: The parent tag.
Head <head>: Contains metadata and the document title.
Body <body>: Contains the main content visible to users.
Example:

<html>
<head>
<title>My First Page</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

full example of html doc if you wanna see

A

<!DOCTYPE html>

<html>
<head>
<meta></meta>
<meta></meta>
<meta></meta>
<meta></meta>
<title>Example HTML Page</title>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>This is an example of a simple HTML document.</p>

<h2>Features of This Page</h2>
<ul>
<li>A structured heading system</li>
<li>Meta tags for better SEO and accessibility</li>
<li>An example of an image and link</li>
</ul>

<img></img>

<p>Visit the <a>example website</a> for more information.</p>
</body>
</html>

Head (<head>): Contains metadata like the title, description, author, and technical settings.
Note: The <title> element is not displayed within the
page content but appears in the browser tab and
search engine results.</title>

Body (<body>): Contains all the visible content for the user, such as headings, paragraphs, images, and links.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the action attribute in an HTML form do?

A

The action attribute specifies the URL where the form data will be sent when submitted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What happens when a form uses the GET method?

A

Data is appended to the URL as query parameters (e.g., /personalData?name=John) and sent to the server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

When should you use the GET method in forms?

A

when:

Data is non-sensitive (e.g., search terms, filters).
URLs need to be shareable or bookmarkable.
Transparency in the request is useful.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the limitations of the GET method?

A

Data is visible in the URL (not secure for sensitive data).
Limited to short data due to URL length restrictions (usually ~2000 characters).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What happens when a form uses the POST method?

A

Data is sent in the HTTP request body (not appended to the URL) and is not visible in the browser’s address bar.

hides it from URL but if you want to make it MORE SECURE:

if you want to make it extremely secure combine with HTTPS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

When should you use the POST method in forms?

A

: Use POST when:

Submitting sensitive data (e.g., passwords, personal details).
Sending large amounts of data (e.g., file uploads).
Modifying server-side resources (e.g., creating or updating data).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the key differences between GET and POST?

A

Q: What are the key differences between GET and POST?
A:

Data Visibility:
GET: Data is appended to the URL and visible.
POST: Data is sent in the request body and hidden.

Suitable For:
GET: Retrieving data.
POST: Submitting or modifying data.

Security:
GET: Not secure for sensitive data.
POST: More secure, especially with HTTPS.

URL Length Limit:
GET: Limited to ~2000 characters.
POST: No limit.

17
Q

Q: How is form data sent in GET vs POST methods?

A

GET Method:
Form data is appended to the URL as a query string.
Each input’s name and value are combined in the format InputName=InputValue.

Multiple inputs are joined with &.
Example (Form):

html
Copy code

<form>
<input></input>
<input></input>
</form>

Resulting URL:

/search?query=HTML&page=1

POST Method:
Form data is sent in the body of the HTTP request, not in the URL.
This makes POST suitable for sending sensitive or large amounts of data.
Key Point:

In GET, data is visible in the URL.
In POST, data is hidden from the URL and sent securely when paired with HTTPS.

18
Q

Given the following HTML form, what would the encoded query string be if the user enters “Samhar Mo as the full name and selects “Brown” as the eye colour?

<form>
<label>Full name:</label>
<input></input><br></br>

<label>Eye colour:
<select>
<option>Black</option>
<option>Green</option>
<option>Brown</option>
</select>
</label><br></br>

<input></input>
</form>

A

query string :
First we always start off with url in form action ? if its get
encodes
input name = Input value

and concatenates ( with &) to form the query string
remember space in input is seen as a + (sign)

essentially anywhere you see name = something
something is your input name

and the value the user actually inputs is the input value

eg here we can see :

name=”fullname”
and
name=”eyecolour”

fullname = Samhar+Mo (plus because their is a space)

eyecolour=Brown
?
query string would therefore be :
/personalData?fullname=Samhar+Mo&eyecolour=Brown

19
Q

if the above was a post instead

A

sent in body would look like

same encoding but this time:
we dont need to extend url to have a query string

in the body of the post wed see the encoding here it is the last line

POST /personalData HTTP/1.1
Host: www.example.com:8080
Accept: text/xml,application/xml,application/xhtml
Accept-Language: en-gb,en-us
Accept-Charset: ISO-8859-1,utf-8
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 37

fullname=Samhar+Mahmoud&eyecolour=Brown

20
Q

XML Tags Rules

A

Case-Sensitive: Tags must match exactly (e.g., <title> ≠ <Title>).</Title></title>

Matching Tags: Every opening tag (<NAME>) must have a corresponding closing tag (</NAME>).

21
Q

Q: What are attributes in XML?

A

Attributes are key-value pairs added to an element’s opening tag to provide extra information or metadata.

example :

<chapter>
<content>This is the first chapter.</content>
</chapter>

element = chapter
attributes:
title = Introduction
number = 1

22
Q

When should attributes be used in XML?

A

A: Use attributes for small, additional metadata that does not require nested elements.

23
Q

Q: What is an XML document, and what is its structure?

A

An XML document is a structured text document used to store and transport data.
It must have:

. Prolog: Appears before the root element and contains:
- XML Declaration (required): Specifies the XML version
and character encoding.

    - Document Type Declaration (DTD) (optional): Defines 
       the schema or structure of the document.

.One Root Element: A single parent element that encloses
all other elements.

Example (Valid XML Document):

<?xml version=”1.0” encoding=”UTF-8”?> (XML Declaration)
<!DOCTYPE book SYSTEM “book.dtd”> ( DTD)

<book>
<title>War and Peace</title>
<author>Leo Tolstoy</author>
</book>

The XML Declaration (required) :

<?xml version=”1.0” encoding=”UTF-8”?>:

The Document Type Declaration (optional) :

<!DOCTYPE book SYSTEM “book.dtd”>

24
Q

Why is the following XML document invalid?

A

<?xml version=”1.0” encoding=”UTF-8”?>

<book>
<title>War and Peace</title>
<author>Leo Tolstoy</author>
</book>

<movie>
<title>Inception</title>
<director>Christopher Nolan</director>
</movie>

This XML is invalid because it has two root-level elements (<book> and <movie>).
XML requires exactly one root element to form a hierarchical tree structure.</movie></book>

How to Fix It:
Wrap both elements inside a single root element:

<?xml version=”1.0” encoding=”UTF-8”?>

<library>
<book>
<title>War and Peace</title>
<author>Leo Tolstoy</author>
</book>
<movie>
<title>Inception</title>
<director>Christopher Nolan</director>
</movie>
</library>

now both of those are wrapped in library which is single root element so now valid

25
Q

Q: What are XML entities, and why are they used

A

XML Entities: Special strings used to safely include reserved characters (like <, >, and &) in XML text or attributes.
Why They Are Used: Reserved characters conflict with XML syntax and must be replaced with entities to make the document valid.
Invalid Example:

<note>
<text>Use < and > for comparisons</text>
</note>

Why Invalid:
The < and > characters conflict with XML syntax because they are treated as tags.
Fixed Example Using Entities:

xml
Copy code

<note>
<text>Use &lt; and &gt; for comparisons</text>
</note>

Entities:
< → <
> → >

26
Q

Q: Why is XML parsing important, and how does it work?

A

Parsing: The process of reading an XML document and converting it into a structured, machine-readable format.

How It Works:
Reserved characters like < are replaced with their actual counterparts (<).
The XML document is converted into a tree structure for programs to work with.

Example:
Given this XML:

<note>
<text>Use &lt; and &gt; for comparisons</text>
</note>

Parsing Output (Tree Structure):

note
└── text: “Use < and > for comparisons”

The < and > entities are replaced with < and > in the parsed output.

27
Q

XML NAMESPACES

A

XML namespaces are used to avoid naming conflicts by specifying which “vocabulary” or “meaning” a tag belongs to in cases where multiple sources (hosts or applications) use the same tag names but with different meanings.

28
Q

How default namespace works

answer :
A default namespace in XML automatically applies to all child elements of the element where it is declared, unless explicitly overridden by specifying another namespace.

A
29
Q
A

NOTES

30
Q
A