HTML Foundation Flashcards
What is doctype and how is it written?
- In HTML, the doctype is the required “<!DOCTYPE html>” preamble found at the top of all documents.
- Its sole purpose is to prevent a browser from switching into so-called “quirks mode” when rendering a document; that is, the “<!DOCTYPE html>” doctype ensures that the browser makes a best-effort attempt at following the relevant specifications.
< !DOCTYPE html >
How do you add references to scripts in your page?
The < script>
HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
< script src="javascript.js"></script > < script> alert("Hello World!"); < /script>
What is an area lable?
Its for text readers.
What does HTML stand for and what does it mean?
HyperText Markup Language
- HyperText refers to pieces of text that can link to other pages or resources. (the first ever website had a lot of links)
- Markup Language - HTML Tags are used to create markup which tells the browser how to interpert and display components on the website.
How many heading levels are there?
6 - h1 to h6
How many heading levels are there?
6 - h1 to h6
What is best practice when using multiple types of headings?
- Use only one < h1 > heading per page. This is the title of the page.
- Do not skip heading levels. Screen readers use headings to quickly skip through content on a page. Dont have < h1 >< /h1 >< h3>< /h3>< h4>< /h4>.
- You can nest headings in lists with lists to help screenreaders.
What is the linebreak html element and what is good practice about using it?
< br >
- The purpose is to break a line of text into a new line.
- It is bad practice to add margins on br tags to create line spacing, rather use the line-height property that was designed for this purpose.
- It is not mean to to create spaces between paragrahps. For that ise the < p> element and use css margin property to create space.
- Creating parahraphs with < br> tags is problematic for screen reading technology.
Why does it matter if you use good practice with HTML
- Many of the best practice recommendations are about accessiblity via screenreaders.
- Cross-browser and cross device compatibility relies on best practice being followed. Some browsers interpret certain things differently, so to be predictable its best to follow good practice.
- Predectibility for other developers. If you follow best practice others will know where to look and what to change.
What is Quirks mode?
- web, pages were typically written in two versions: One for Netscape Navigator, and one for Microsoft Internet Explorer.
- When the web standards were made at W3C, browsers could not just start using them, as doing so would break most existing sites on the web. Browsers therefore introduced two modes to treat new standards compliant sites differently from old legacy sites
- There are now three modes used by the layout engines in web browsers: quirks mode, limited-quirks mode, and no-quirks mode.
- In quirks mode, layout emulates behavior in Navigator 4 and Internet Explorer 5.
- This is essential in order to support websites that were built before the widespread adoption of web standards.
- In no-quirks mode, the behavior is (hopefully) the desired behavior described by the modern HTML and CSS specifications. In limited-quirks mode, there are only a very small number of quirks implemented.
Why are some html elements self closing? Do they need the slash?
Self closing tags mean they do net have content like <br></br> or <br></br>
In HTML 5 a void element (one that does not have content) does not need a closing slash.
The slash at the end of the closing tag is an XHTML thing, but HTML 5 does not require it.
What is the horizontal rule tag, best practice and attributes applicable?
< hr> Represents a thematic break between paragraph-level elements: for example, a change of scene in a story, or a shift of topic within a section.
HR is not actually meant for styling, its more semantic. For actually lines use CSS.
Besides the global attributes you can also use the following:
align Deprecated Non-standard
Sets the alignment of the rule on the page. If no value is specified, the default value is left.
color Deprecated Non-standard
Sets the color of the rule through color name or hexadecimal value.
noshade Deprecated Non-standard
Sets the rule to have no shading.
size Deprecated Non-standard
Sets the height, in pixels, of the rule.
width Deprecated Non-standard
Sets the length of the rule on the page through a pixel or percentage value.
What is an HTML attribute?
Its information in the html element that tells the browser how to interpret it. e.g. < hr size=”3” >
What are global attributes?
Global attributes are attributes common to all HTML elements; they can be used on all elements, though they may have no effect on some elements.
The list can be found here - https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
How do you write a comment in HTML?
< !– comment here – >
Write the HTML Boilerplate.
what is the < html lang="eng" >< /html>
tag
- This is the HTML root element and represents the root/top level of an HTML document.
- ALL other elements are decendants of this element.
- Its permitted content is a
<head>
element followed by a<body>
element. - The lang attributed will tell screen readers how to interpet the website.
- HTML 5 does not require the HTML tag, but its good for adding the lang tag or styling.
What is the <head>
element?
- The Document Metadata (Header) element. It follows the
<html>
element. - Contains machine-readable information (metadata) about the document, like its title, scripts, and style sheets.
- It does not display in the browser.
What is the <title>
element?
- Written
<title></title>
. - Defines the title that is shown in the title bar.
- It only contains text and is always in the head lement.
- Page titles are important for SEO.
What is the <link>
element?
- Written
<link>
. - The External Resource Link element.
- Its a self closing tag.
- It specifies the relationship between the current html document and an external source. Commonly used to link stylesheets.
- To link an external stylesheet write
<link href="main.css" rel=stylesheet">
- To link a favicon write
<link rel ="icon" href="favicon.ico">
- There are a number of other icon rel values, mainly used to indicate special icon types for use on various mobile platforms.
What is the <style>
element and its best practice?
- The
<style>
element must be included inside the<head>
of the document. In general, it is better to put your styles in external stylesheets and apply them using<link>
elements. - If you include multiple
<style> and <link>
elements in your document, they will be applied to the DOM in the order they are included in the document — make sure you include them in the correct order, to avoid unexpected cascade issues. - In the same manner as
<link> elements, <style>
elements can include media attributes that contain media queries, allowing you to selectively apply internal stylesheets to your document depending on media features such as viewport width.
What are media queries?
- Introduced in CSS3
- Media queries are not limited to CSS. They can be used in other languages such as JavaScript and HTML. However, CSS is the most common language used for media queries
- Media queries allow you to apply CSS styles depending on a device’s general type or other characteristics such as screen resolution or browser viewport width.
Media queries are used for the following:
- To conditionally apply styles with the CSS @media and @import at-rules.
- To target specific media for the <style>, <link></link>, <source></source>, and other HTML elements with the media= attribute.
- To test and monitor media states using the Window.matchMedia() and EventTarget.addEventListener() methods.</style>