Masterclass Flashcards
For the sake of easy maintenance, your website’s styles are in a .css file, so that it can be used in multiple pages. What HTML element and attribute are used to specify an external stylesheet?
‹link rel=”stylesheet” type=”text/css” href=”theme.css”›
A lengthy web page “mypage.htm” contains various headings. How would you create a link to this web page so that a specific heading at the bottom of the page, “Credits”, comes into view when your link is clicked?
First, create a bookmark the bottom heading, ‹a name=”credits”›Credits‹/a›. Then, the link will be constructed as ‹a href=”mypage.htm#credits”›Open Credits page‹/a›
On a web page, when the link to a page called “somepage.htm” is clicked, the page is expected to load in an ‹iframe› element. Give the skeleton HTML code of how this can be done.
‹a href=”somepage.htm” target=”myiframe”›Open Some Page‹/a› ‹iframe id=”myiframe”›‹/iframe›
How would you make content contained within a ‹table› element available to a screen reader that is meant to assist the visually impaired?
By adding a summary of the table using the summary attribute. The summary attribute’s value is available to screen readers.
[table summary=”Monthly savings for the Flintstones family”]
On a contact information web page, the users need to be redirected to a separate confirmation and “Thank you” page called “thanks.htm”. Give a skeleton of the HTML code that would achieve the redirection.
‹form action=”thanks.htm”›
An online dating site requires users to submit their picture as part of the registration process. Give a skeleton of the HTML code showing how you would implement a web page interface so that a file can be uploaded. You may assume that a server-side script called “ihandleuploads.php” is going to process the data.
‹form action=”ihandleuploads.php” enctype=”multipart/form-data” method=”post”› ‹input type=”file” /›
‹input type=”submit” /›
‹/form›
On a legacy system created by a client who wanted to try out their hand at HTML, you find that the tag that takes the password on the user registration page is showing the password text as it is being typed. How would you fix this?
By changing the type attribute to “password” instead of “text”
Your client has moved to a new domain name “newfoo.com”, but still retains the old name “oldfoo.com”. However, the client wishes to redirect users to the new site automatically. But the old site’s hosts do not have any server-side scripts enabled, so the
redirection has to be done using HTML only. How would you do this?
‹meta http-equiv=”refresh” content=”0;url=http://www.newfoo.com”›
When you search for your name using Bing or Google, your site comes on the first page of results. However, you would like to show a description of your site below its URL on these search results. What HTML element and attribute can achieve this?
The ‹meta› element placed in the ‹head› section would allow this, given that the “name” attribute is set to “description” and the required description itself is given in the “content” attribute of the element. For instance, ‹meta name=”description” content = “My description here”›
All links on an archives web page are pointing to a previous version of the current website. The old version was at a different domain name “oldfoothatwassuchalongname.com”. Given that all links contain “http://oldfoothatwassuchalongname.com/” before the name of the page, what HTML- only method is available to save code space by not repeating this common URL and still make the old links work?
In the ‹head› area, the ‹base› element can be used to set the target URL of all the links on this page:
‹head›
‹base href=”http://oldfoothatwassuchalongname.com/” /›
‹/head›
There are some web pages that you do not wish for search engines like Google to crawl or index. What meta tag is useful to stop these search engines?
The robots tag type can achieve this, but has to be placed at the head of each of the pages. ‹meta name=”robots” content=”noindex, nofollow”›
You wish to avoid your HTML code being rendered incorrectly by newer browsers that can interpret HTML as XML by default. How would you specify the markup language version to avoid any problems?
Using the ‹!DOCTYPE› declaration, before the ‹html› tag.
You wish to make search engines be aware of the date your web page was last updated. How would you achieve this?
‹meta http-equiv=”last-modified” content=”date time here”›
Cookies are useful in saving data to the client browser securely. Give a code skeleton of how you would initialize this process using HTML by setting a cookie.
‹meta http-equiv=”set-cookie” content=”feedme=1;expires=Expiry date time here; path=/”›
You are maintaining legacy CSS code, you notice that the visibility attribute for an image has been set to visibility: collapse. Is this an error, and what effects would this have?
This is a valid value for the visibility attribute. However, it is only valid for tables. For the image, this value will produce the same effect as visibility: hidden