HTML Document Standards Flashcards
<!DOCTYPE html>
Must be the first line of code in an HTML document
What must be the second line of code in an HTML document so that HTML structure and content can be created or inputted?
<html></html>
Head Element
<head></head>
Used for metadata of a webpage
Title Element
<title></title>
Tab’s title
Anchor Element
<a></a>
A link
Must have an href attribute
href Attribute
href=hypertext reference. This attribute is what will contain the URL for the anchor element. Any content put in the anchor element is what the link will say.
Target Attribute
Specifies how a link should open.
For example, _blank means the link will open in a new window.
Linking to a Relative Page
When having a link to a relative page, it is going to be a relative path instead of an absolute path. The link will be to a file in the same folder as the file you are already one.
A relative path is a filename that shows the path to a local file (a file on the same website, such as ./index.html) versus an absolute path (a full URL, like https://www.codecademy.com/learn/learn-html which is stored in a different folder). The ./ in ./index.html tells the browser to look for the file in the current folder.
Linking an Image
Put an anchor element outside of an image element
Linking to the Same Page
In order to link to a target on the same page, we must give the target an id, like this:
<p>This is the top of the page!</p>
<h1>This is the bottom! </h1>
An id should be descriptive to make it easier to remember the purpose of a link. The target link is a string containing the # character and the target element’s id.
<ol>
<li><a>Top</a></li>
<li><a>Bottom</a></li>
</ol>
In the example above, the links to <p id="top"> and <h1 id="bottom"> are embedded in an ordered list. These links appear in the browser as a numbered list of links. An id is especially helpful for organizing content belonging to a div!
Do not wrap the entire <li> element in the anchor element, only the content inside.
Comments
<!--comment-->
Helps you (and others) understand your code if you decide to come back and review it at a much later date. Also allows you to experiment with new code, without having to delete old code.