HTML (Hypertext Markup Language)
HTML (Hypertext Markup Language) is a text-based approach to describing how content contained within an HTML file is structured. This markup tells a web browser how to display text, images, and other forms of multimedia on a webpage.
HTML is a formal recommendation by the World Wide Web Consortium (W3C) and is generally adhered to by all major web browsers, including both desktop and mobile web browsers. HTML5 is the latest version of the specification.
How HTML worksHTML is a text file containing specific syntax, file, and naming conventions that show the computer and the web server that it is in HTML and should be read as such. By applying these HTML conventions to a text file in virtually any text editor, a user can write and design a basic webpage, and then upload it to the internet.
The most basic of HTML conventions is the inclusion of a document type declaration at the beginning of the text file. This always comes first in the document, because it is the piece that affirmatively informs a computer that this is an HTML file. The document header typically looks like this: <!DOCTYPE html>. It should always be written that way, without any content inside it or breaking it up. Any content that comes before this declaration will not be recognized as HTML by a computer.
Doctypes are not just used for HTML, they can apply to the creation of any document that uses SGML (Standard Generalized Markup Language). SGML is a standard for specifying a specific markup language being used. HTML is one of several markup languages that SGML and doctype declarations apply to.
The other critical requirement for creating an HTML file is saving it with a .html file extension. Whereas the doctype declaration signals HTML to the computer from the inside of the file, the file extension signals HTML to the computer from the outside of the file. By having both, a computer can tell that it's an HTML file whether it's reading the file or not. This becomes especially important when uploading the files to the web because the web server needs to know what to do with the files before it can send them to a client computer for the inner contents to be read.
After writing the doctype and saving it as an HTML file, a user can implement all the other syntactic tools of HTML to customize a web page. Once finished, they will likely have several HTML files corresponding to various pages of the website. It's important that the user uploads these files in the same hierarchy that they saved them in, as each page references the specific file paths of the other pages, enabling links between them. Uploading them in a different order will cause links to break and pages to be lost, because the specified file paths will not match the pages.
Basic elements of HTMLUsing HTML, a text file is further marked up with additional text describing how the document should be displayed. To keep the markup separate from the actual content of the HTML file, there is a special, distinguishing HTML syntax that is used. These special components are known as HTML tags. The tags can contain name-value pairs known as attributes, and a piece of content that is enclosed within a tag is referred to as an HTML element.
HTML elements always have opening tags, content in the middle, and closing tags. Attributes can provide additional information about the element and are included in the opening tag. Elements can be described in one of two ways:
Pros of using HTML include:
A few cons to consider are:
HTML tags dictate the overall structure of a page and how the elements within them will be displayed in the browser. Commonly used HTML tags include:
As mentioned, there are opening and closing tags that surround the content they are augmenting. An opening tag looks like this: <p>. A closing tag is the same but contains a backslash in it to indicate that it's the end of the given HTML element. Closing tags look like this: </p>.
How to use and implement HTMLBecause HTML is completely text-based, an HTML file can be edited simply by opening it up in a program such as Notepad++, Vi, or Emacs. Any text editor can be used to create or edit an HTML file and, so long as it is named with a .html file extension, any web browser -- such as Chrome or Firefox -- will be capable of displaying the file as a webpage.
For professional software developers, there are a variety of WYSIWYG editors to develop webpages. NetBeans, IntelliJ, Eclipse, and Microsoft's Visual Studio provide WYSIWYG editors as either plugin or as standard components, making it incredibly easy to use and implement HTML.
These WYSIWYG editors also provide HTML troubleshooting facilities, although modern web browsers often contain web developer plugins that will highlight problems with HTML pages, such as a missing closing tag or syntax that does not create well-formed HTML.
Chrome and Firefox both include HTML developer tools that allow for the immediate viewing of a webpage's complete HTML file, along with the ability to edit HTML on the fly and immediately incorporate changes within the internet browser.
HTML, CSS and JavaScriptHTML is used to create webpages but does experience limitations when it comes to fully responsive components. Therefore, HTML should only be used to add text elements and structure them within a page. For more complex features, HTML can be combined with cascading style sheets (CSS) and JavaScript (JS).
An HTML file can link to a cascading style sheet or JS file -- usually at the top of the document with a specified file path -- which will contain information about which colors to use, which fonts to use and other HTML element rendering information. JavaScript also allows developers to include more dynamic functionality, such as pop-ups and photo sliders, in a webpage. Tags called class attributes are used to match HTML elements to their corresponding CSS or JS elements.
For example, if a user wants the color of a certain amount of text to be red, they can write code in the CSS file with an accompanying class attribute that turns text red. Then they can place the associated class attribute on all the pieces of text they want to be red in the HTML sheet. The same basic method applies to JS sheets, with different functions.
Separating information about how a page is structured, the role of HTML, from the information about how a webpage looks when it is rendered in a browser is a software development pattern and best practice known as separation of concerns.
History and developmentIn the early days of the world wide web, marking up text-based documents using HTML syntax was more than sufficient to facilitate the sharing of academic documents and technical memos. However, as the internet expanded beyond the walls of academia and into the homes of the general population, greater demand was placed on webpages in terms of formatting and interactivity.
HTML 4.01 was released in 1999, at a time when the internet was not yet a household name, and HTML5 was not standardized until 2014. During this time, HTML markup drifted from the job of simply describing the document structure of webpage content into the role of also describing how content should look when a webpage displays it.
As a result, HTML4-based webpages often included information within a tag about what font to use when displaying text, what color should be used for the background, and how content should be aligned. Describing within an HTML tag how an HTML element should be formatted when rendered on a webpage is considered an HTML antipattern. HTML should generally describe how content is structured, not how it will be styled and rendered within a browser. Other markup languages are better suited to this task.
One major difference between HTML4 and HTML5 is that the separation of concerns pattern is more rigorously enforced in HTML5 than it was in HTML4. With HTML5, the bold <b> and italicize <i> tags have been deprecated. For the paragraph tag, the align attribute has been completely removed from the HTML specification.
HTML versionsThe following is a list of HTML versions and the years they were created. Several iterations of each version have been released over time. This list aims to focus on significant iterations.
HTML5 introduces several elements to increase interactivity, multimedia capabilities, and semantic efficiency. Instead of using plugins, multimedia can be placed within the HTML code. These elements include:
Other main features of HTML5 include:
While the addition of these features represents an effort to support multimedia embedding, changes to the HTML specification demonstrate the desire of the community for HTML to return to its original purpose of describing the structure of content. Basically, more structural features have been added, while several format-centric features have been deprecated. For the purpose of backward-compatibility, web browsers will continue to support deprecated HTML tags, but eventually, HTML will be mainly structure-based.
HTML syntax standardsIn the following HTML example, there are two HTML elements. Both elements use the same paragraph tag, designated with the letter p, and both use the directional attribute dir, although a different attribute value is assigned to the HTML attribute's name-value pairing, namely RTL and ltr.
Notice that when this HTML snippet is rendered in a browser, the HTML tags impact how each HTML element is displayed on the page, but none of the HTML tags or attributes are displayed. HTML simply describes how to render the content. The HTML itself is never displayed to the end-user.
In order for a web browser to display an HTML page without error, it must be provided with well-formed HTML. To be well-formed, each HTML element must be contained within an opening tag -- <p> -- and a closing tag -- </p>. Furthermore, any new tag opened within another tag must be closed before the containing tag is closed. So, for example, <h1><p>well-formed HTML</p></h1> is well-formed HTML, while <h1><p>well-formed HTML</h1></p> is not well-formed HTML.
Another syntax rule is that HTML attributes should be enclosed within single or double-quotes. There is often debate about which format is technically correct, but the World Wide Web Consortium asserts that both approaches are acceptable.
The best advice for choosing between single and double quotes is to keep the usage consistent across all the documents. HTML style-checkers can be used to enforce consistent use across pages. It should be noted that sometimes using a single quote is required, such as in an instance where an attribute value actually contains a double quote character. The reverse is true as well.
It's important to note as well that the language HTML works with is basic English. Non-English characters -- or letters -- such as Chinese, or special symbols -- like letters with accent marks -- may not display correctly on a webpage by default. In order to accommodate special character sets, users need to specify the character encoding with an element that looks like this: <meta charset="utf-8"/>. In this case, utf-8 is the character set. Utf-8 is HTML's default English charset.
0 Comments
Post a Comment