HTML Flashcards
Where do you put non-visible content about the HTML document?
Non-visible content, also known as meta-data, can be placed in the head of an HTML document. This content is not displayed on the web page itself, but is used by web browsers, search engines, and other web-based applications to provide context and additional information about the document.
There are a variety of HTML elements that can be used to include meta-data in the head of an HTML document, including:
title: This element specifies the title of the document, which is used by web browsers and search engines as the title of the page.
meta: This element is used to provide metadata about the document, such as the author, description, keywords, and other information.
link: This element is used to link the document to other resources, such as stylesheets, favicons, and other documents.
script: This element is used to include JavaScript code in the document, which can be used to add interactive functionality to the page.
Where do you put visible content about the HTML document?
Visible content in an HTML document is typically placed within the body element. The body element contains all of the content that is displayed in the web browser when the page is loaded, including text, images, videos, and other media.
Where do the <head> and <body> tags go in a valid HTML document?
In a valid HTML document, the head element must be placed within the html element, immediately after the opening html tag. The body element must be placed within the html element, immediately after the head element.
What is the purpose of a <!DOCTYPE> declaration?
The DOCTYPE declaration is used to specify the type of HTML document. It is placed at the top of an HTML document, before the html element. By specifying a DOCTYPE declaration, you can ensure that the web browser uses standards mode to render the document, which can help to ensure consistent behavior across different web browsers.
Give five examples of HTML element types.
Here are five examples of HTML element types:
p: The p element represents a paragraph of text.
img: The img element represents an image.
form: The form element represents an HTML form, which is used to collect input from users.
table: The table element represents an HTML table, which is used to display data in a grid format.
div: The div element represents a division or section of the document. It is often used as a container for other HTML elements.
What is the purpose of HTML attributes?
HTML attributes are used to provide additional information about HTML elements. They are added to the opening tag of an element and take the form of name-value pairs.
Attributes can be used to specify a wide variety of information about an element, such as its id, class, style, src (for images), href (for links), and many other things.
Attributes are optional and an HTML element can have any number of attributes, depending on the needs of the document.
Give an example of an HTML entity (escape character).
An HTML entity is a special character or symbol that can be represented in HTML using a combination of letters and numbers. These entities are used to display characters that are not available on all keyboards or that have special meaning in HTML.
In this example, the < and > characters are replaced with the < and > entities, respectively. These entities are known as escape characters and are used to represent the < and > characters in HTML.
There are many different HTML entities that can be used in HTML documents. Some common examples include:
&nsb; : non-breaking space
©: copyright symbol
€: Euro symbol
™: trademark symbol
—: em dash
“: left double quotation mark
”: right double quotation mark
How do block-level elements affect the document flow?
Block-level elements are HTML elements that are formatted as blocks, which means that they take up the full width of their parent container and create a new line before and after themselves. Some examples of block-level elements include div, h1, p, and table.
Block-level elements affect the document flow in several ways:
They create a new line before and after themselves: Because block-level elements take up the full width of their parent container and create a new line before and after themselves, they can be used to structure the content of a web page into distinct sections or blocks.
They can contain inline elements and other block-level elements: Block-level elements can contain both inline elements (such as a, em, and strong) and other block-level elements. This allows you to create complex and hierarchical layouts using a combination of block-level and inline elements.
They can be styled using CSS: You can use CSS to style block-level elements in a variety of ways, such as setting their background color, font size, margins, and padding. This allows you to create a wide range of layouts and visual styles for your web pages.
They affect the way the document is read by assistive technologies: Block-level elements can affect the way the document is read by assistive technologies, such as screen readers. For example, a screen reader might announce the start and end of a block-level element, or use a different voice to distinguish between different types of block-level elements.
How do inline elements affect the document flow?
Inline elements are HTML elements that are formatted within the flow of a document, rather than as blocks that create a new line before and after themselves. Some examples of inline elements include a, em, strong, and img.
Inline elements affect the document flow in several ways:
They do not create a new line before or after themselves: Because inline elements do not create a new line before or after themselves, they can be used to add small amounts of content within a block of text or other block-level element.
They can only contain other inline elements: Inline elements can only contain other inline elements, not block-level elements. This means that they cannot be used to create complex or hierarchical layouts.
They are affected by the styling of their parent element: Inline elements are affected by the styling of their parent element, as well as by any inline styles applied to them directly. This means that you can use CSS to style inline elements, but the styles will be inherited from the parent element and may be overridden by any inline styles.
They do not affect the way the document is read by assistive technologies: In general, inline elements do not affect the way the document is read by assistive technologies, such as screen readers. These technologies tend to focus on block-level elements and the content within them, rather than on individual inline elements.
What are the default width and height of a block-level element?
The default width and height of a block-level element depend on the type of element and the parent element it is contained within.
Here are a few general rules to keep in mind:
By default, block-level elements take up the full width of their parent element. For example, if a div element is contained within a body element, it will typically take up the full width of the browser window.
The default height of a block-level element is determined by its content. If the element contains text or other elements, it will be tall enough to contain all of its content. If the element is empty, it will have a default height of 0.
You can use CSS to set the width and height of block-level elements. For example, you can use the width and height properties to set the width and height of a div element.
You can also use the display property to change the way an element is displayed. For example, you can use display: inline-block to make a block-level element behave like an inline element, or display: none to hide the element completely.
It’s important to note that these rules are not absolute and can be overridden by other factors, such as the presence of other elements or the use of CSS.
What are the default width and height of an inline element?
The default width and height of an inline element depend on the type of element and the content it contains.
Here are a few general rules to keep in mind:
By default, inline elements take up only the space required by their content. For example, if an a element contains a single word, it will be as wide as that word and as tall as the font size of the text.
The default height of an inline element is determined by the font size of the text it contains. If the element is empty, it will have a default height of 0.
The default width of an inline element is determined by the content it contains and the width of its parent element. If the element contains text that wraps to multiple lines, it will be as wide as its parent element.
You can use CSS to set the width and height of inline elements, but these properties may not have the desired effect. In general, it is best to use block-level elements if you need to set the width and height of an element.
It’s important to note that these rules are not absolute and can be overridden by other factors, such as the presence of other elements or the use of CSS.
What is the difference between an ordered list and an unordered list in HTML?
An ordered list in HTML is a list of items that are numbered in a specific order. An unordered list is a list of items that are not numbered, but are marked with bullet points.
Is an HTML list a block element or an inline element?
An HTML list (either an ordered list or an unordered list) is a block-level element. This means that it takes up the full width of its parent element and creates a new line before and after itself.
What HTML tag is used to link to another website?
The a (anchor) element is used to create a hyperlink to another website in HTML. The a element is an inline element, which means that it can be used within a block of text or other inline elements.
You can use the a element to link to any type of web resource, including other HTML pages, images, PDF files, and more. You can also use the a element to create links to specific locations within the same page or to a different page on the same website.
What is an absolute URL?
An absolute URL is a complete web address that includes the protocol (such as “http” or “https”), the domain name, and the path to a specific resource on the web.
Here is an example of an absolute URL:
Copy code
https://www.example.com/path/to/resource
In this example, “https” is the protocol, “www.example.com” is the domain name, and “/path/to/resource” is the path to the specific resource.
Absolute URLs are used to specify the exact location of a web resource and can be used to link to resources on the same website or on another website.