Beginner HTML - Elements and Structure Cheatsheet - Codecademy
Beginner HTML - Elements and Structure Cheatsheet - Codecademy
Element Content
The content of an HTML element is the information
between the opening and closing tags of an element. <h1>Codecademy is awesome! 🙂</h1>
<ul>
<li>Cookies</li>
<li>Milk</li>
</ul>
video. Adding the controls attribute will display video Video not supported
</ol>
<div> elements can contain flow content such as <h1>A section of grouped elements</h1>
headings, paragraphs, links, images, etc. <p>Here’s some text for the section</p>
</div>
<div>
</div>
HTML Structure
HTML is organized into a family tree structure. HTML
elements can have parents, grandparents, siblings, <body>
</div>
</body>
Closing Tag
An HTML closing tag is used to denote the end of an
HTML element. The syntax for a closing tag is a left angle <body>
required, like in a postal address. The line break element Poems are a great use case.<br>
requires only an opening tag and must not have a closing Oh joy! A line break.
tag.
...
Unique ID Attributes
In HTML, specific and unique id attributes can be
assigned to different elements in order to differentiate <h1 id="A1">Hello World</h1>
between them.
When needed, the id value can be called upon by CSS
and JavaScript to manipulate, format, and perform
specific instructions on that element and that element
only. Valid id attributes should begin with a letter and
should only contain letters ( a-Z ), digits ( 0-9 ), hyphens
( - ), underscores ( _ ), and periods ( . ).
HTML Attributes
HTML attributes are values added to the opening tag of an
element to configure the element or change the <p id="my-paragraph" style="color:
element’s default behavior. In the provided example, we green;">Here’s some text for a paragraph
are giving the <p> (paragraph) element a unique that is being altered by HTML
identifier using the id attribute and changing the color attributes</p>
of the default text using the style attribute.
<ul> Unordered List Element
The <ul> unordered list element is used to create a list
of items in no particular order. Each individual list item <ul>
</ul>
alt Attribute
An <img> element can have alternative text via the alt
attribute. The alternative text will be displayed if an image <img src="path/to/image" alt="text
fails to render due to an incorrect URL, if the image describing 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.
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.
document. </body>
HTML Tag
The syntax for a single HTML tag is an opening angle
bracket < followed by the element name and a closing <div>
angle bracket > . Here is an example of an opening
<div> tag.
<a href="http://www.codecademy.com">
</a>
</head>
</html>
nesting. <h1>Heading</h1>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>
</div>
<a href="#id-of-element-to-link-to">Take
me to a different part of the page</a>
contained between the opening and closing <html> tags. <!-- I'm a comment -->
</html>
Comments
In HTML, comments can be added between an opening
<!-- and closing --> . Content inside of comments will <!-- Main site content -->
Comments can be
-->
Whitespace
Whitespace, such as line breaks, added to an HTML
document between block-level elements will generally be <p>Test paragraph</p>
</head>
</html>
File Path
URL paths in HTML can be absolute paths, like a full URL,
for example: https://developer.mozilla.org/en- <a href="https://developer.mozilla.org/en-
US/docs/Learn or a relative file path that links to a local file US/docs/Web">The URL for this anchor
in the same folder or on the same server, for example: element is an absolute file path.</a>