unit-2 question and answer
unit-2 question and answer
Ans:- The <html> element is the root element and it defines the whole HTML document. It has a start tag
<html> and an end tag </html> . The <body> element defines the document's body. It has a start tag
<body> and an end tag </body> .
DOCTYPE>: It defines the document type or it instruct the browser about the version of HTML.
<html > :This tag informs the browser that it is an HTML document. Text between html tag describes the
web document. It is a container for all other elements of HTML except <!DOCTYPE>
<head>: It should be the first element inside the <html> element, which contains the
metadata(information about the document). It must be closed before the body tag opens.
<title>: As its name suggested, it is used to add title of that HTML page which appears at the top of the
browser window. It must be placed inside the head tag and should close immediately. (Optional)
<body> : Text between body tag describes the body content of the page that is visible to the end user.
This tag contains the main content of the HTML document.
Heading Tags:- Any document starts with a heading. You can use different sizes for your headings. HTML
also has six levels of headings, which use the elements <h1>, <h2>, <h3>, <h4>, <h5>, and <h6>.
While displaying any heading, browser adds one line before and one line after that heading.
Paragraph Tag
The <p> tag offers a way to structure your text into different paragraphs. Each paragraph of text should go
in between an opening <p> and a closing </p> tag
Line Break Tag
Whenever you use the <br /> element, anything following it starts from the next line. This tag is an
example of an empty element, where you do not need opening and closing tags, as there is nothing to go
in between them.
Horizontal Lines
Horizontal lines are used to visually break-up sections of a document. The <hr> tag creates a line from the
current position in the document to the right margin and breaks the line accordingly.
1) Bold Text
HTML<b> and <strong> formatting elements. The HTML <b> element is a physical tag which display text
in bold font, without any logical importance. If you write anything within <b>............</b> element, is
shown in bold letters.
2) Italic Text
HTML <i> and <em> formatting elements
The HTML <i> element is physical element, which display the enclosed content in italic font, without any
added importance. If you write anything within <i>............</i> element, is shown in italic letters.
3) HTML Marked formatting
If you want to mark or highlight a text, you should write the content within <mark>.........</mark>.
4) Underlined Text
If you write anything within <u>.........</u> element, is shown in underlined text.
5) Strike Text
Anything written within <strike>.......................</strike> element is displayed with strikethrough. It is a thin
line which cross the statement.
6) Monospaced Font
If you want that each letter has the same width then you should write the content within <tt>.............</tt>
element.
7) Superscript Text
If you put the content within <sup>..............</sup> element, is shown in superscript; means it is displayed
half a character's height above the other characters.
8) Subscript Text
If you put the content within <sub>..............</sub> element, is shown in subscript ; means it is displayed
half a character's height below the other characters.
9) Deleted Text
Anything that puts within <del>..........</del> is displayed as deleted text.
10)Smaller Text
If you want to put your font size smaller than the rest of the text then put the content within
<small>.........</small>tag. It reduces one font size than the previous one.
Q3 Discuss Image tag with attributes, give example
Image
HTML img tag is used to display image on the web page. HTML img tag is an empty tag that contains
attributes only, closing tags are not used in HTML image element.
Let's see an example of HTML image.
<h2>HTML Image Example</h2>
<img src="good_morning.jpg" alt="Good Morning Friends"/>
1) src
It is a necessary attribute that describes the source or path of the image. It instructs the browser where to
look for the image on the server.
The location of image may be on the same directory or another server.
2) alt
The alt attribute defines an alternate text for the image, if it can't be displayed. The value of the alt
attribute describe the image in words. The alt attribute is considered good for SEO prospective.
3) width
It is an optional attribute which is used to specify the width to display the image. It is not recommended
now. You should apply CSS in place of width attribute.
4) height
It h3 the height of the image. The HTML height attribute also supports iframe, image and object elements. It
is not recommended now. You should apply CSS in place of height attribute.
Example
<html>
<head>
<title>Image tag</title>
</head>
<body>
<h2>HTML image example with height and width</h2>
<img src="https://static.javatpoint.com/htmlpages/images/animal.jpg" height="180" width="300"
alt="animal image">
</body>
</html>
Q4 Write program for inserting audio and video in web page?
How Audio, video are inserted in web page? Give tag used
Ans:- Audio Tag
HTML audio tag is used to define sounds such as music and other audio clips. Currently there are three
supported file format for HTML 5 audio tag.
1. mp3
2. wav
3. ogg
HTML5 supports <video> and <audio> controls. The Flash, Silverlight and similar technologies are used to
play the multimedia items.
There is given a list of HTML audio tag.
Attribute Description
controls It defines the audio controls which is displayed with play/pause buttons.
autoplay It specifies that the audio will start playing as soon as it is ready.
loop It specifies that the audio file will start over again, every time when it is completed.
muted It is used to mute the audio output.
preload It specifies the author view to upload audio file when the page loads.
src It specifies the source URL of the audio file.
Example:-
<html>
<body>
<audio controls autoplay loop>
<source src="koyal.mp3" type="audio/mpeg"></audio>
</body>
</html>
Video Tag
HTML 5 supports <video> tag also. The HTML video tag is used for streaming video files such as a movie
clip, song clip on the web page.
Currently, there are three video formats supported for HTML video tag:
1. mp4
2. webM
3. ogg
Let's see the table that defines which web browser supports video file format.
Let's see the list of HTML 5 video tag attributes.
Attribute Description
controls It defines the video controls which is displayed with play/pause buttons.
height It is used to set the height of the video player.
width It is used to set the width of the video player.
poster It specifies the image which is displayed on the screen when the video is not played.
autoplay It specifies that the video will start playing as soon as it is ready.
loop It specifies that the video file will start over again, every time when it is completed.
muted It is used to mute the video output.
preload It specifies the author view to upload video file when the page loads.
src It specifies the source URL of the video file.