Document?
- Document may be excel file, or may be word file, etc
now, i'm taking about html file.
whole page or page is called document.
Example -
<!Doctype.html>
<html>
<head>
<title> This is page Title</title>
</head>
<body>
WELCOME TO HTML INTERVIEW QUESTIONS
</body>
</html>
How browser look like?
Tag ?
Tag used for e.g. <div></div>
<html></html> ==> html tag
<head></head> ==> head tag
Object ?
Element and attribute in our page is an Object
Node is document object model
Tree structure is call model
How does JavaScript understand this HTML document.
When the HTML document is loaded in the Browser corresponding
to that document another representation of that document is created which is
kown as the document object model
Each tag like <html> <head>
corresponding document object model
Another representation
Same hirerachy key created here
Same HTML document represents as different format
javascript interprets this format
documents object model terms of nodes
three different nodes
Element node
Text node
Attribute Node
objct attribute, method as well as fucntion
1. HTML Element Syntax?
An HTML element is an individual component of an HTML document.
It represents semantics, or meaning.
For example, the title element represents the title of the document.
Most HTML elements are written with a start tag (or opening tag) and an end tag (or closing tag), with content in between. Elements can also contain attributes that defines its additional properties. For example, a paragraph, which is represented by the p element, would be written as:
2. HTML Tags Vs Elements?
Technically, an HTML element is the collection of start tag, its attributes, an end tag and everything in between. On the other hand an HTML tag (either opening or closing) is used to mark the start or end of an element, as you can see in the above illustration.
However, in common usage the terms HTML element and HTML tag are interchangeable i.e. a tag is an element is a tag. For simplicity's sake of this website, the terms "tag" and "element" are used to mean the same thing — as it will define something on your web page.
Note: Full line is called Elements.
3. What is the difference between HTML elements and tags?
HTML elements communicate to the browser to render text. When the elements are enclosed by brackets <>, they form HTML tags. Most of the time, tags come in a pair and surround content.
HTML documents contain two thing
content, tags.
example1: <tag> content </tag>
example2: <h1> content </h2>
5. What is a DOCTYPE?
Ans: According to HTML standards, each HTML documentation begins with DOCTYPE declaration that specifies which version of HTML the document uses.
6. HTML Tags, Attributes and Elements
...................................................................................................................................................................................................................................
Example #1
<!DOCTYPE html>
<html>
<head>
<title> my title</title>
<script type="text/javascript">
function add() {
var a = 2;
var b = 3;
var c = a + b
document.write('Results ', c)
}
add()
</script>
</head>
<body>
</body>
</html>
...................................................................................................................................................................................................................................
Example #2 [ NaN]
<!DOCTYPE html>
<html>
<head>
<title> my title</title>
<script type="text/javascript">
function add(a,b) {
var c = a + b
document.write('Results ', c)
}
add()
</script>
</head>
<body>
</body>
</html>
...................................................................................................................................................................................................................................
...................................................................................................................................................................................................................................
No comments:
Post a Comment