Elements in HTML-interview
You are building a webpage and want to emphasize a specific word inside a paragraph. You decide to use the <b> tag.
Is it valid to place a <b> tag inside a <p> tag ? What does this do ?
Is it valid to place a <b> tag inside a <p> tag ? What does this do ?
Yes, it is completely valid. In HTML, you can nest a <b> (bold) tag inside a <p> (paragraph) tag. This means you are emphasizing a specific portion of the paragraph by making it bold. The <p> tag acts as the parent container for the paragraph text, and the <b> tag is the child element used to highlight or stress part of that text. This enhances readability and draws user attention to key parts of the content.
You are writing a short bio on your website and want to display the text on two lines without starting a new paragraph.
Which HTML tag would you use to insert a line break, and is it a self-closing tag ?
Which HTML tag would you use to insert a line break, and is it a self-closing tag ?
You should use the <br> tag. It is a self-closing tag specifically designed to insert a line break within the same paragraph or block of text. This allows the content to continue on the next line without adding extra space like a new paragraph would. Since <br> does not wrap content, it doesn't require a closing tag.