Basics to HTML

HTML is Hypertext Markup Language. It provides the basic text that would display on the webpage. You can only edit the text style that's shown on the site. More advanced editing will use CSS for additional display or location formats.

HTML consists of a series of elements and the elements are represented by tags. Each tag with a closing tag is essentially is an element. Inline elements do not start on a new line; they take only the necessary width. Block elements will start on a new line and take the full width available.

Block Level: <div>, <h1> - <h6>, <p>, <form>

Inline level: <span>, <img>, <a>

To open a page in a new tab use target = "_blank". Generally used for external sites

HTML tag syntax format is generally set up as <tagname> attributename="attributevalue">content</tagname>

Attributes

Attributes go inside opening tags. They could be global attributes like class & id. Class attribute lets us style elements with CSS or selectors with JavaScript.

All tags can have attributes, they provide informatioon about an element. They can have 'key' or value pairs or ID tags. (id="someID")

Miscellaneous Display Tips

For special characters that would trigger code and not display properly, you would use the '&' symbol followed for the character code.
For example, to display & symbol you would use '&amp;'.
For the '<' you would use '&lt' and the for '<' symbol, you would use '&gt;'.

Inserting Tabs or Spaces

Lorem ipsum in visual studio will automatically fill it, or lorem10 for 10 words to test it.

Text Formatting

Text formatting elements were designed to display special types of text.

Block Quote, Abbreviations, Citing

Quotation and Citation Elements - <blockquote>,<q>, <abbr>, <address>, <cite>, and <bdo>

Images

The <img> tag is used to insert images. Images are self closing and do not require a closing tag. They always include a 'src' or source attribute to define where the image directory is located.

The file path is case sensitive, so if there is a typo then the image will show the alt text. Src attributes can go to either another website/absolute URL or relative URL. Relative URLs are better so they will not break if you change domains.

The 'alt' attribute will provides alternate text for an image when it cannot be displayed properly.

The following is an example of using the image tag:

			<a href="/sample-site/images/example.jpg">
				<website-project/sample-site/images/CupAdventure.jpg" alt="Simple Sample Image" width="300">
			</a>
        

Which displays the following:

Simple Sample Image

The <a> tag is used to create hyperlinks. When you have the directory for the image as a the hyperlink, it essentially functions like viewing the image from your web browser.

Images are not technically inserted into a web page but are linked to web pages. The <img> tag creates a holding space for the referenced image. HTML allows animated gifs

List Items

Creating Tables

Generated by using the <table> element tag.

Enclosed in the tag is the <thead> tag the which represents the heading row which includes all of the column names. You need to create the <tr> tag which is represented by table row followed by <th> tag to display column names.

Like the rest of HTML, the <body> tag follows the <head> tag. Tables use the <tbody> element tag. Instead of using <tr> tag, the <tbody> tag utilizes <td> tag for table data.

In order you create additional rows, you would just use another line with the <td> tag nested in between the table row <tr> tag.

Table Example

Below is an example of a simple table.

			<table>
				<thead>
				<tr>
						<th>Name</th>
						<th>Phone Number</th>
						<th>Email </th>
					</tr>
				<thead>
				<tbody>
					<tr>
						<td>John Doe</td>
						<td>777-888-9999</td>
						<td>jdoe@webdomain.com</td>
					</tr>
					<tr>
						<td>Jane Doe</td>
						<td>777-878-7878</td>
						<td>janedoe@webdomain.com</td>
					</tr>
					<tr>
						<td>First Wednesday</td>
						<td>777-555-8787</td>
						<td>1stwed@webdomain.com</td>
					</tbody>
					</table>        
        

This code displays the following:

Name Phone Number Email
John Doe 777-888-9999 jdoe@webdomain.com
Jane Doe 777-878-7878 janedoe@webdomain.com
First Wednesday 777-555-8787 1stwed@webdomain.com

Creating Forms

You can create forms on HTML, however you cannot add functions to it. You can build the actual output display however it requires another language with dynamic functionality to store or use the data.
Usually with a form, it will have an attribute called action that references another file to submit the form to another page like a news form or register form followed by a post method.

Syntax Example: <form action="process.css" method="POST">

Methods are generally requests to a server using POST action which adds data to a database without displaying the data submitted in the URL as opposed to the GET action that does display it in the URL. The GET action is usually used by search functions where you do not enter any data to a server.

The <label> tag is used to create a label that doesn't have any fields to insert data. You would generally use the <input> tag to create a field.
Both <label> and <input> tags are both inline by default. In order to separate them, you would use the <div> tag to put each field into it's own block.

Below is an example of a simple table.

Form Example

Below is an example of some basic form options

The form is generated using the following HTML5 code:

			<form action="process.css" method="POST">
				<div>
					<label>First Name:</label>
					<input type="text" name="firstName" placeholder="Enter first name">
				</div>
				<div>
					<label>Last Name:</label>
					<input type="text" name="lastName" placeholder="Enter last name">
				</div>
				<div>
					<label>Email:</label>
					<input type="email" name="emailAddress">
				</div>
				<div>
					<label>Birthday:</label>
					<input type="date" name="birthday>
				</div>
				<div>
					<label>Quantity</label>
					<input type="number" name="quantity" value="1">
				</div>
				<div>
					<label>Topic:</label>
					<select name ="emailTopic">
						<option value ="newOrder">New Order</option>
						<option value ="customerService">General Customer Service</option>
						<option value ="productSupport">Order Support</option>
						<option value ="suggestiions">Suggestions</option>
						<option value ="other">Other</option>
					</select>
				</div>
				<div>
					<label>Message:</label>
					<textarea name="message"></textarea>
				</div>
				<input type="submit" name="submit" value="Submit">
			</form>
		

The type input attribute in the example defines what type of data is being submitted. There are various type attributes:

The name input attribute is meant for serverside programming and the attribute is how we would call the value from the form.

The <textarea> tag with the name textarea attribute is used to create the message field where you can click and drag the corner to edit the size of the text box.

The "value" input attribute displays black text in the field. Use the "placeholder" input attribute instead in order to display faded gray text.

**The <input type="submit name="submit" value="Submit"> before the </form> closing tag creates a button that submits the form to a process the action defined in the form tag.

Buttons

<Button> tags are just as the tag name implies, they create a button but function but to have to be added using javascript or other functions

HTML5 Semantic Tags

A semantic element clearly describes it's meaning to both the developer and the browser. Generally used to lay out your website.

Example Layout

			<html>
				<head>
					<title>Blogs for Days</title>
					<meta name="description" content="simple sample blog">
					<meta name="keywords" content="simple sample blog company name">
				</head>
				<body>
					<header id="main-header">
						<h2>My Very Own Blog Website</h2>
					</header>
					
					<a href="index.html">Go to Home Page</a>
					
					<section>
						<article class="post">
							<h3>First Post: Day 1</h3>
							<small>Posted by John Doe on May 4, 2021</small>
							<p>Each article that goes here will be a blog post. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
							<small><a href="post.html">Read more...</a></small>
						</article>
						
						<article class="post">
							<h3>Second Post: Week 1</h3>
							<small>Posted by John Doe on May 11, 2021</small>
							<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
							<small><a href="post.html">Read more...</a></small>
						</article>
						
						<article class="post">
							<h3>Third Post: Week 3</h3>
							<small>Posted by John Doe on May 24, 2021</small>
							<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
							<small><a href="post.html">Read more...</a></small>
						</article>
					</section>
					
					<aside>
						<h2>Categories</h2> 
						<nav>
							<ul>
								<li><a href="#">Category 1</a></li>
								<li><a href="#">Category 2</a></li>
								<li><a href="#">Category 3</a></li>
							</ul>
						</nav>
					</aside>
					
					<footer id="main-footer">
						<p>Copyright © 2021</p>
					</footer>
			</body>
			</html> 
        

This displays the following:

Blogs for Days

My Very Own Blog Website

Go to Home Page

First Post: Day 1

Posted by John Doe on May 4, 2021

Each article that goes here will be a blog post. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Read more...

Second Post: Week 1

Posted by John Doe on May 11, 2021

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Read more...

Third Post: Week 3

Posted by John Doe on May 24, 2021

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Read more...