HTML & JavaScript
HTML & JavaScript
HTML Document
Consists of elements marked by tags and attributes of elements.
Initially, HTML documents were created using only elements with presentational attributes.
As web technologies advanced, the concept evolved to include documents that can change
dynamically and have the characteristics of applications.
Learning Content
HTML Document
A collection of DOCTYPE and elements.
DOCTYPE
Indicates the protocol used to structure the document.
<!DOCTYPE>
Starts with <!DOCTYPE> to indicate the type of document.
If a web document lacks DOCTYPE information, the web browser cannot accurately determine
the protocol used in the document, which may lead to improper rendering.
<!DOCTYPE html>: HTML5 document protocol.
<html> Element
Represents the content of the document.
The document may include a collection of elements for representing various sizes of headings,
paragraphs, lists, and tables.
<head> Element
<title> Element
Indicates the document title.
<meta> Element
Other Elements
● <script> element: Script for interactions with users on a web document using
JavaScript.
● <style> element: CSS (Cascading Style Sheets) used for the presentation of the web
document.
● <link> element: Links to external JavaScript and CSS files referenced in the web
document.
Element
Attribute
Represents information about the element.
Consists of pairs of names and values.
Attribute: id
Value: my_id
Actual content: HTML
Tag
A type of label added to document content to mark elements in the document.
Tag
● Start tag to indicate the beginning of an element: composed of the < character, the tag
name, and the > character.
● End tag to indicate the end of an element: composed of </, the tag name, and the >
character.
● Some elements are assumed to have an end tag even if it's not present.
● It's best to include the end tag when possible.
● Self-closing tag: composed of <, the tag name, and /> for elements that do not contain
other elements or content.
● Composite Tag: Used for elements that have both a start tag and an end tag.
● Self-Closing Tag: A tag that indicates both the start and end, used for elements that do
not contain content.
Examples
● <title> element: A composite tag composed of a start tag <title> and an end tag
</title>.
● <img> element: A self-closing tag represented as <img/>.
Attribute
Used to provide additional information to an element.
Additional Information
Attribute