HTML Notes
HTML
HTML Tags and Elements
Attributes and Hyperlinks
Headings and Lists
Class and id attributes
Semantic Elements
Inline and Block-Level Elements
Div and Span
img
Tables
Forms
Heading
Q
1
Give a short note on HTML Attributes.
Ans
1.HTML attributes are special words which provide additional information about the elements or attributes are the modifier of the HTML element.
2. Each element or tag can have attributes, which defines the behaviour of that element.
3. Attributes should always be applied with start tag.
4. The Attribute should always be applied with its name and value pair.
5. The Attributes name and values are case sensitive, and it is recommended by W3C that it should be written in Lowercase only.
6. You can add multiple attributes in one HTML element, but need to give space between two attributes.
Syntax
<element attribute_name="value">content</element>
Q
2
Why do we need Attributes in HTML?
Ans
An attribute is a specification that defines a property of an object, element, or file. It may also refer to or set the specific value for a given instance of such. For clarity,attributes should more correctly be considered metadata.
Q
3
Can attributes be modified dynamically?
Ans
we can modify it by using JavaScript
syntax
document.getElementByTagName("tag name").setAttribute("attribute name", "value");
Q
4
Give a short note on the title and lang attributes in HTML
Ans
The title attribute is used as text tooltip in most of the browsers. It display its text when user move the cursor over a link or any text. You can use it with any text or link to show the description about that link or text. In our example, we are taking this with paragraph tag and heading tag.
Example
With <h1> tag:
<h1 title="This is heading tag">Example of title attribute</h1>
Q
5
Define Hyperlinks.
Ans
A hyperlink is an element in an HTML document that links to either another portion of the document or to another document altogether. On webpages, hyperlinks are usually colored purple or blue and are sometimes underlined.
The href attribute is the main attribute of <a> anchor tag. This attribute gives the link address which is specified in that link. The href attribute provides the hyperlink, and if it is blank, then it will remain in same page.
Example
With link address:
<a href="https://www.javatpoint.com/html-anchor">This is a link</a>