Mod 3 Flashcards
What are HTML elements?
HTML structures documents by using elements. Elements can stand on their own or be nested within other elements. For example, a paragraph element might exist within a section element or a table row will be within a table. The way elements are represented in HTML is by using a pair of opening and closing tags. An opening tag has the element name enclosed in <> and a closing tag has the element name enclosed in </>.
Example:
<h1>Display this as the highest level heading.</h1>
What are the parts in the basic structure of an HTML document?
-The first line <!DOCTYPE html> is called the Document Type Declaration.
-Following this, we have the <html> element which is the root element of the document. Often has lang attribute.
-Inside the <html> element, we have the elements <head> and <body>.
What is a <head> element in HTML?
The <head> element is used to specify meta-data about the document and is also called the header of the document. It helps the browser and robots (e.g., search engine crawlers) understand what is on the page.
Within <head> - </head>, the browser tab title will show the contents of the <title> element.</title>
What is a <body> element in HTML?
The <body> element contains the actual content which will be visible in the browser. The actual content the user will see all goes in the body of the page.
What are HTML attributes?
Attributes are used to provide additional information about an element. Attributes are usually specified using the syntax of attribute-name=”attribute-value” or attribute-name=’attribute-value’.
Example:
<input></input>
The type attribute of this element determines the behavior of this element.
The checked attribute doesn’t have a value. A check-box is checked if the attribute checked exists and it is unchecked if that attribute does not exist. The value of the checked attribute is meaningless.
What are HTML entities?
Certain characters in HTML are reserved for special use. We can display these characters using entities, which act as special codes for characters. Entities are strings that begin with & and end with ; and are provided to display reserved characters as well as characters that may be difficult to type on a keyboard.
Entity Description
< Displays <
> Displays >
& Displays &
" Displays “
In HTML, what is the difference between block-level elements and in-line elements?
Block-level elements break up the flow on the content and are typically displayed by browsers with a newline both before and after the element. (like <p>)
As opposed to this in-line elements do not break the flow of the content. (like <span>)</span>
When should you use an HTML Heading?
If you would potentially find something listed in the table of contents, it is a great candidate for a heading. Headings should be used to add organization to a document. So any section or sub section that needs a title can use a heading for it. One could make a good argument that they could also be used to add a title to something like an image.
Headings should be used for organization, not style.
What is an HTML <div> element used for?
The div element, e.g., <div>Content Here</div>, is used to divide content. It should be used as a last resort when no other element makes sense. If you want to divide content purely for stylistic reasons this is the element to use. It conveys no meaning and just generically divisions content.
What is an HTML <section> element used for?
The section is used to make a thematic grouping of content. It is a group of content that is all related but does not quite stand on its own. Usually the first child of a section will be a heading that describes what is in that section. If there is not a good way to classify the content in the section using a heading, you may want to consider using a div instead. A section should only be used if all the content is related.
What is an HTML <article> element used for?
The article element is structurally the same as the section except that it is an <article> tag instead of a <section> tag. The requirements for a article are stricter than a section. Not only should the content all be related but the content should generally stand on its own as a composition.
What is an HTML <anchor> element?</anchor>
The content between the <a> and </a> tags should describe the link when someone clicks to navigate to it. The href attribute is used to specify the URL where the link will take the user when it is clicked.
Example:
<a>A link to MDN.</a>
The anchor element can also be used to link to a specific location in a document. To do this:
- Add an id attribute to the element we want to link to ( Like: <h2 id="browsers">Browsers</h2>)
- In the URL, add the value of the id attribute at the end, preceded by a hash symbol #.
How does the HTML img element work?
The img tag is used to display images: <img></img>. The src attribute is required and indicates the URL where the image is located. No closing tag is used for images. By default images display in-line. So no new line is made for them. The alt attribute is not required, but is very important for accessibility.
What is the HTML <strong> element?</strong>
The strong element marks text that is more important, e.g., <strong>This is important</strong>. It requires an opening and closing tag.
What is the HTML <b> element?</b>
The b element makes text stylistically different from other text. Look at me, I am <b>different</b>. This could be used to highlight keywords in a paragraph or conform to style guidelines set by some journal. It does not give additional meaning to the text. Text inside a b element is no more important than text outside of the b element.