Coding
Coding
<body>
</body>
For unordered lists, also known as bullet points, start with the <ul> tag
and wrap each item in a <li> list item element. Like so:
We can use the <a> anchor element! This link tag allows us to add
a hyperlink to a piece of text.
What if we want to add images? We can use a similar format, but with
the <img> image element.
<img src="https://i.redd.it/5unn16axx1v81.jpg">
Note: This can also be used to point to an email or phone number using
a mailto:, tel:, or sms: parameter:
<a href="mailto:[email protected]">📧</a>
<a href="tel:212-555-2368">🤙</a>
<a href="sms:320-250-HTML">💬</a>
CHAPTER 2
all HTML files must start with a <!DOCTYPE html> declaration and
the <html> element:
<!DOCTYPE html>
<html>
</html>
<body> contains all of the content that you will end up seeing on the
page.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
They are usually name/value pairs, like name="value", where the name and
value are separated by an equals sign:
<element name="value">Content</element>
<ol type="a">
<li>Power ⚡</li>
<li>Courage 🔥</li>
<li>Wisdom 🦉</li>
</ol>
In addition to src, we can also use the alt attribute to make our images more
accessible.
<img alt="pixel girl using a laptop"
src="https://www.codedex.io/images/tier1.png">
If our image can't appear for some reason, the alt text is displayed instead!
This allows assistive devices to read our text and describe the image. 🦻🏻
<a href="https://www.codedex.io/">Codédex</a>
The href attribute is where we add a URL that can be visited when the
hyperlinked text is clicked.
We can also use the target attribute and set it to "_blank" to make the link
open in a new browser tab:
The two attributes we'll come across most are the class and id attributes.
Any element can use them. While class and id are used for labeling
elements, the two have important differences.
Additionally, id can be used to link to another part of the same page, such as
the heading! This can be matched with an <a> anchor
element's href attribute via a # hashtag symbol, followed by the identifier
used for the id:
Lastly, where only one id can be assigned to a single element, a class can be
assigned to many:
<h2>About Me</h2>
</div>
<h2>Social:</h2>
<ul>
<li>GitHub</li>
<li>Twitter</li>
<li>LinkedIn</li>
</ul>
</div>
First, we can apply a style attribute to any HTML element to stylize certain
aspects of that element, such as what color the text should be:
<p>
</p>
<p>
</p>
The <img> tag should also contain the width and height attributes, which
specify the width and height of the image (in pixels):
Example
You should always include the lang attribute inside the <html> tag, to
declare the language of the Web page. This is meant to assist search engines
and browsers.
<!DOCTYPE html>
<html lang="en">
<body>
...
</body>
</html>
Bigger Headings
Each HTML heading has a default size. However, you can specify the size for
any heading with the style attribute, using the CSS font-size property:
Example
<h1 style="font-size:60px;">Heading 1</h1>
The <hr> tag defines a thematic break in an HTML page, and is most often
displayed as a horizontal rule.
Example
Example
<pre>
My Bonnie lies over the ocean.
Example
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
Example
<body>
</body>
Text Color
The CSS color property defines the text color for an HTML element:
Example
Fonts
The CSS font-family property defines the font to be used for an HTML
element:
Example
Text Size
The CSS font-size property defines the text size for an HTML element:
Example
Text Alignment
The CSS text-align property defines the horizontal text alignment for an
HTML element:
Example
Example
Tip: Use the global title attribute to show the description for the
abbreviation/acronym when you mouse over the element.
Example
The HTML <address> tag defines the contact information for the
author/owner of a document or an article.
The HTML <cite> tag defines the title of a creative work (e.g. a book, a
poem, a song, a movie, a painting, a sculpture, etc.).
The HTML <bdo> tag is used to override the current text direction:
Example
Border Color
Internal CSS
The following example sets the text color of ALL the <h1> elements (on that
page) to blue, and the text color of ALL the <p> elements to red. In addition,
the page will be displayed with a "powderblue" background color:
Example
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
CSS Padding
The CSS padding property defines a padding (space) between the text and
the border.
Example
p{
border: 2px solid powderblue;
padding: 30px;
}