Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created June 6, 2020 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/604a4849e6c2d23ca44c7dc9ecf45155 to your computer and use it in GitHub Desktop.
Save codecademydev/604a4849e6c2d23ca44c7dc9ecf45155 to your computer and use it in GitHub Desktop.
Codecademy export
<!DOCTYPE html>
<html>
<head>
<title>HTML/CSS Cheatsheet</title>
<link href="./styles.css" type="text/css" rel="stylesheet">
</head>
<body>
<div>
<header>
<img src="https://bit.ly/3eIeIX6" height="250" width="200" alt="profile picture">
<h6>Created by GymGeekRay</h6>
<h1 class="title">My Cheat Sheet</h1>
</header>
</div>
<div>
<h2>Elements & Structure</h2>
<h3>HTML</h3>
<p>HTML (HyperText Markup Language) is used to give content to a web page and instructs web browsers on how to structure that content.</p>
<br>
<h3>HTML Element</h3>
<p>An HTML element is a piece of content in an HTML document and uses the following syntax: opening tag + content + closing tag.In the code provided:</p>
<ul>
<li><strong>&lt;p&gt;</strong> is the opening tag.</li>
<li><strong>Hello World!</strong> is the content.</li>
<li><strong>&lt/p&gt;</strong> is the closing tag.</li>
</ul>
<br>
<h3>HTML Tag</h3>
<p>The syntax for a single HTML tag is an opening angle bracket &lt; followed by the element name and a closing angle bracket &gt;. Here is an example of an opening &lt;div&gt; tag.</p>
<br>
<h3>Element Content</h3>
<p>The content of an HTML element is the information between the opening and closing tags of an element.</p>
<p>&lt;<strong>h1</strong>&gt;Codecademy is awesome!&lt;<strong>/h1</strong>&gt;</p>
<br>
<h3>Closing Tag</h3>
<p>An HTML closing tag is used to denote the end of an HTML element. The syntax for a closing tag is a left angle bracket &lt; followed by a forward slash / then the element name and a right angle bracket to close &gt;.</p>
<br>
<h3>HTML Stucture</h3>
<p>HTML is organized into a family tree structure. HTML elements can have parents, grandparents, siblings, children, grandchildren, etc.</p>
<br>
<h3>HTML Attributes</h3>
<p>HTML attributes are values added to the opening tag of an element to configure the element or change the element’s default behavior.</p>
<br>
<h3>Attribute Name and Values</h3>
<p>HTML attributes consist of a name and a value using the following syntax: <em>name=value</em> and can be added to the opening tag of an HTML element to configure or change the behavior of the element.</p>
<br>
<h3>Unique ID Attributes</h3>
<p>In HTML, specific and unique id attributes can be assigned to different elements in order to differentiate between them.<br>
When needed, the <em>id</em> value can be called upon by CSS and JavaScript to manipulate, format, and perform specific instructions on that element and that element only. Valid <em>id</em> attributes should begin with a letter and should only contain letters (a-Z), digits (0-9), hyphens (-), underscores (_), and periods (.).</p>
<br>
<h3>Alt Attribute</h3>
<p>An &lt;img&gt; element can have alternative text via the <em>alt</em> attribute. The alternative text will be displayed if an image fails to render due to an incorrect URL, if the image format is not supported by the browser, if the image is blocked from being displayed, or if the image has not been received from the URL.<br>
The text will be read aloud if screen reading software is used and helps support visually impaired users by providing a text descriptor for the image content on a webpage.</p>
<br>
<h3>Document Type Declaration</h3>
<p>The document type declaration &lt;!DOCTYPE html&gt; is required as the first line of an HTML document. The doctype declaration is an instruction to the browser about what type of document to expect and which version of HTML is being used, in this case it’s HTML5.</p>
<br>
<h3>File Path</h3>
<p>URL paths in HTML can be absolute paths, like a full URL, for example: <strong>https://developer.mozilla.org/en-US/docs/Learn</strong> or a relative file path that links to a local file in the same folder or on the same server, for example: <em>./style.css.</em> Relative file paths begin with ./ followed by a path to the local file. ./ tells the browser to look for the file path from the current folder.</p>
<br>
<h3>Link to a Different Part of the Page #</h3>
<p>The anchor element &lt;a&gt; can create hyperlinks to different parts of the same HTML document using the <em>href</em> attribute to point to the desired location with <em>#</em> followed by the <em>id</em> of the element to link to.</p>
<br>
<h3>Whitespace</h3>
<p>Whitespace, such as line breaks, added to an HTML document between block-level elements will generally be ignored by the browser and are not added to increase spacing on the rendered HTML page. Rather, whitespace is added for organization and easier reading of the HTML document itself.</p>
<br>
<h3>Indentation</h3>
<p>HTML code should be formatted such that the indentation level of text increases once for each level of nesting.
It is a common convention to use two or four space per level of nesting.</p>
<br>
<h3>Comments</h3>
<p>In HTML, comments can be added between an opening <em>&lt;!--</em> and closing --&gt;. Content inside of comments will not be rendered by browsers, and are usually used to describe a part of code or provide other details.
Comments can span single or multiple lines.</p>
<br>
</div>
<!--Elements and structure above this comment-->
<div>
<h2>Element Tags</h2>
<table>
<thead>
<th>Tag</th>
<th>Name</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td><span class="code">&lt;body&gt;</span></td>
<td>Body Element</td>
<td>The &lt;body&gt; element represents the content of an HTML document. Content inside &lt;body&gt; tags are rendered on the web browsers.
</td>
</tr>
<br>
<tr>
<td><span class="code">&lt;h1&gt;-&lt;h6&gt;</span></td>
<td>Heading Elements</td>
<td>HTML can use six different levels of heading elements. The heading elements are ordered from the highest level &lt;h1&gt; to the lowest level &lt;h6&gt;.</td>
</tr>
<br>
<tr>
<td><span class="code">&lt;div&gt;</span></td>
<td>Div Element</td>
<td>The &lt;div&gt; element is used as a container that divides an HTML document into sections and is short for “division”. &lt;div&gt; elements can contain <em>flow content</em> such as headings, paragraphs, links, images, etc.</td>
</tr>
<tr>
<td><span class="code">&lt;p&gt;</span></td>
<td>Paragraph Element</td>
<td>The &lt;p&gt; paragraph element contains and displays a block of text.</td>
</tr>
<tr>
<td><span class="code">&lt;span&gt;</span></td>
<td>Span Element</td>
<td>The &lt;span&gt; element is an inline container for text and can be used to group text for styling purposes. However, as &lt;span&gt; is a generic container to separate pieces of text from a larger body of text, its use should be avoided if a more semantic element is available.</td>
</tr>
<tr>
<td><span class="code">&lt;em&gt;</span></td>
<td>Emphasis Element</td>
<td>The &lt;em&gt; emphasis element emphasizes text and browsers will usually <em>italicize</em> the emphasized text by default.</td>
</tr>
<tr>
<td><span class="code">&lt;strong&gt;</span></td>
<td>Strong Element</td>
<td>The &lt;strong&gt; element highlights important, serious, or urgent text and browsers will normally render this highlighted text in <strong>bold</strong> by default.</td>
</tr>
<tr>
<td><span class="code">&lt;br&gt;</span></td>
<td>Line Break Element</td>
<td>The &lt;br&gt; line break element will create a line break in text and is especially useful where a division of text is required, like in a postal address. The line break element requires only an opening tag and must not have a closing tag.</td>
</tr>
<tr>
<td><span class="code">&lt;ul&gt;</span></td>
<td>Unordered List Element</td>
<td>The &lt;ul&gt; unordered list element is used to create a list of items in no particular order. Each individual list item will have a bullet point by default.</td>
</tr>
<tr>
<td><span class="code">&lt;li&gt;</span></td>
<td>List Item Element</td>
<td>The &lt;li&gt; list item element create list items inside: Ordered lists &lt;ol&gt;
Unordered lists &lt;ul&gt;
</td>
</tr>
<tr>
<td><span class="code">&lt;ol&gt;</span></td>
<td>Ordered List element</td>
<td>The &lt;ol&gt; ordered list element creates a list of items in sequential order. Each list item appears numbered by default.</td>
</tr>
<tr>
<td><span class="code">&lt;img&gt;</span></td>
<td>Image Element</td>
<td>HTML image &lt;img&gt; elements embed images in documents. The <em>src</em> attribute contains the image URL and is mandatory. &lt;img&gt; is an empty element meaning it should not have a closing tag.</td>
</tr>
<tr>
<td><span class="code">&lt;video&gt;</span></td>
<td>Video Element</td>
<td>The &lt;video&gt; element embeds a media player for video playback. The <em>src</em> attribute will contain the URL to the video. Adding the <em>controls</em> attribute will display video controls in the media player.</td>
</tr>
<tr>
<td><span class="code">&lt;html&gt;</span></td>
<td>HTML Element</td>
<td>The &lt;html&gt; element, the root of an HTML document, should be added after the !DOCTYPE declaration. All content/structure for an HTML document should be contained between the opening and closing &lt;html&gt; tags.</td>
</tr>
<tr>
<td><span class="code">&lt;head&gt;</span></td>
<td>HEAD Element</td>
<td>The &lt;head&gt; element contains general information about an HTML page that isn’t displayed on the page itself. This information is called metadata and includes things like the title of the HTML document and links to stylesheets.</td>
</tr>
<tr>
<td><span class="code">&lt;title&gt;</span></td>
<td>Title Element</td>
<td>The &lt;title&gt; element contains a text that defines the title of an HTML document. The title is displayed in the browser’s title bar or tab in which the HTML page is displayed. The &lt;title&gt; element can only be contained inside a document’s &lt;head&gt; element.</td>
</tr>
<tr>
<td><span class="code">&lt;a&gt;</span></td>
<td>Anchor Element</td>
<td>The &lt;a&gt; anchor element is used to create hyperlinks in an HTML document. The hyperlinks can point to other webpages, files on the same server, a location on the same page, or any other URL via the hyperlink reference attribute, <em>href</em>. The <em>href</em> determines the location the anchor element points to.</td>
</tr>
<tr>
<td><span class="code">&lt;target&gt;</span></td>
<td>Target Attribute</td>
<td>The <em>target</em> attribute on an &lt;a&gt; anchor element specifies where a hyperlink should be opened. A <em>target</em> value of "_blank" will tell the browser to open the hyperlink in a new tab in modern browsers, or in a new window in older browsers or if the browser has had settings changed to open hyperlinks in a new window.</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
body {
font-family: arial;
background-color: DimGrey;
}
h1 {
border: dotted Deeppink;
text-align: center;
color: HotPink;
}
h2 {
color: HotPink;
text-align: center;
}
h3 {
color: HotPink;
}
table {
border: dotted HotPink;
width: 650px;
margin: 0 auto;
}
thead {
background-color: PaleVioletRed;
}
td {
border-top: 4px double pink;
}
.code {
font-family: monospace;
background-color: LightPink;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment