WebDesign HTML/CSS Flashcards
Question
Answer
What does HTML stand for?
Hyper Text Markup Language
Which doctype declaration does HTML5 use?
< !DOCTYPE html >
How do you declare a headline?
< h1 >…< /h1 >
sizes range from 1 to 6
How do you declare paragraphs in HTML?
< p >…< /p >
Give the hyperlink tag to a homepage Sweetheart.com.
< a href=”http://www.sweetheart.com” > This is the link to Sweetheart< /a >
- the page will open in the current window
Explain < img src=”w3schools.jpg” alt=”W3Schools.com” width=”104” height=”142” >. (4)
- tag to display an image
- the src attribute links to where the image is located, in this case, the same folder the HTML file is in
- alt is the text that is displayed if you hover over the picture or that is displayed in case the picture won’t load
- width and height refer to the display properties, not the actual size of the image, it will be resized to fit
What does the < body > element define?
- the document body or what is actually displayed/visible on the web page
What does the < html > element define?
the whole document
How do you close a break element? Why should you close it when it is anyway empty?
< br / >
- close all elements if you need stricter validation or make your document readable by XML parsers
How can you display a tool tip about an element for screen readers? (3)
< p title=”paragraph about zoos in Chicago” >text text< /p >
- screen reader reads it to a blind person
- is also displayed when you hover over element
< p title=”mouse” >< /p >
What is the tag to create a horizontal line in HTML?
< hr / >
< br / > is an … HTML element for creating a …
…empty…line break
What is the < head > element for?
-it only contains meta data-permissible elements: < title >, < meta >, < style >, < link >, < script >, < noscript > and < base >
How do you avoid the “poem problem”, that lines and spaces are ignored in HTML?
If you wrap paragraphs not in < p >, but in < pre > tags, all spaces will be honoured.< pre >text will show this way< / pre >
< pre > defines…
pre-formatted text.
The … element defines emphasised text (italics), with added … importance.
…< em > …semantic
How do you italicise “flower” in the following text paragraph?< p >The red poppy, was the famous flower blooming across Flanders during WWI< / p >
< p >The red poppy, was the famous < i >flower< / i > blooming across Flanders during WWI< / p >< em > also italicises, but with added semantic importance; do not use it for formatting alone!
How do you format text in bold?
< b >text< / b > bold formatting< strong >< / strong > bold formatting with added semantic importance
How do you highlight text by colouring its background, similarily to using a text marker in a book?
< mark >text< / mark > …text will be highlighted in front of a yellow background
How can you can you create strikethrough formatting? And why would this be used?
< del >puppy< / del > …puppy will be cancelled out-emphasises that something is now deleted and still inform users that it once existed/was considered/etc.
How can you show through formatting that particular text was added to a paragraph?
< p >< ins >Bunnies< / ins > are cute.< / p >
How do you create a subscript in HTML such as is required for a logarithms base?
< sub >…< / sub >
How can you reformat HTML to a smaller sized text with direct formatting?
textsuitable for footmarks
How can you reformat HTML to a smaller sized text with direct formatting?
< small >text< / small > -suitable for footmarks
In HTML, how do you format short quotes correctly?
< q >Flowers are beautiful!< / q > -text in quotes will normally be wrapped in quotation marks
In HTML, how do you format long quotes (several lines) correctly? (3)
< blockquote >text text< / blockquote >-quote will generally be indented-you can inbuilt a reference to the source: cite=”http://www.text.com”
In HTML5, what is a clever way to show your readers what an abbreviation stands for?
< abbr title=”Woof Dog Home” >WDH< / abbr >
With HTML tags, how can you show/highlight text to the reader designated as computer code? (3)
< code >command blah< / code >-you can achieve richer effects with CSS-text is usually displayed in the font family Monospace
With HTML tags, how can you show/highlight text similar to computer code as keyboard input or computer output? (3)
< samp >sample output< / samp >< kbd >keyboard input< / kbd >-all displayed in font family Monospace
How do you insert comments in HTML, which show text or code that should not be displayed in the browser, for example reminders or for debugging?
In HTML5, what is the tag for defining/formatting a mathematical variable?
< var >x< / var >
What does CSS stand for?
Cascading Style Sheets
What are the 3 ways in which CSS can be added to HTML?
-inline - with a style attribute in tags-internal - with a style element in the head section-external - by linking to an external .css file
What is the general CSS syntax for internal / external CSS?
element { property:value ; property:value }element…HTML, e.g. pproperty…CSS, e.g. colorvalue…CSS, e.g. red
Why would you use inline styling for CSS?
To apply a unique styling to a single HTML element.
Why would you use internal styling for CSS?
You can define a common style for all HTML elements on a page, e.g. every instance where you find an H1 heading it will be displayed in red.
Use internal CSS styling to colour the page background black, to double the size of the h1 headlines and to change the font of text to Verdana.
body { color:black;}h1 { font-size:200%;}p { font-family:verdana;}
“Colour” the following text in blue using inline CSS styling. Assume it’s a headline of the highest order.Come to the Blue Mountains today!
< h1 style=”color: blue;” >Come to the Blue Mountains today!< / h1 >
Why would you use external style sheets?
The same styling can be applied to several pages of a homepage at once.
What is the CSS Box Model?
~every HTML element has a box around it, even if its invisible~with CSS you can make it visible with the border property and style it
How do you link to an external style sheet called minnie.css?
in the head section: < link rel=”stylesheet” type=”text/css” href=”minnie.css” >
What does the CSS padding property do and how?
-defines a space inside the border of an HTML elementp { padding:10px; }
What does the CSS margin property do and how?
-defines a margin outside the border of an HTML elementp {margin:30px; }
How do you make the invisible box around an HTML element visible?
p { border:1px solid black; }
You can internally style HTML elements by referring to them directly in the head section, but how can you achieve a different styling for some items or an item of the same type of element?
1) use the id attribute to assign an individual styling for a single element2) use the class attribute to assign a styling to you chosen group of elements
Show how the id attribute is used on a p element called “bunny”, which should be coloured blue.
p#bunny { color:blue; }< p id=”bunny” >Bunnies are different< / p >
Show how the class attribute is used on 2 p elements of the group to be called “error”, which should be coloured red.
p.error { color:red; } < p class=”error” >I beg to differ.< / p >< p class=”error” >I differ, too.< / p >
What is the difference linking to another website and linking to a different page within your website?
-linking outside requires an absolute URL (a full web address with http://)-linking within uses a relative URL, e.g. a page in the current folder can be targeted by just linking to the pages title
By default, links will appear like this in all browsers:-an unvisited link –a visited link –an active link -
~an unvisited link - underlined & blue~a visited link - underlined & purple~an active link - underlined & red
How can you change the default link colours for hover, visited, active and default with CSS?
a:hover {color:yellow; background-color:black}a:visited {color:red; background-color:black}a:active {color:blue; background-color:transparent}a:link {color:black; background-color:transparent}
The target attribute of a link specifies…
…where to open the linked document.
Open http://www.lambda.info in a new window or tab using HTML.
< a href=”http://www.lambda.info” target=”_blank” >Visit Lambda!< / a >
Open http://www.omega.info in the parent frame using HTML.
< a href=”http://www.omega.info” target=”_parent” >Visit Omega!< / a >
Open http://www.potatoes.info in the full body of the window using HTML.
< a href=”http://www.potatoes.info” target=”_top” >Visit Potatoes!< / a >-if page is locked in a frame, you can break out of it with _top
How do you target frames via a link?
< a href=”http://www.candice.edu” target=”framename” >Directory< / a >
How do you turn an image into a link? (3)
-wrap the link around the image-don’t forget to add alt and style-style=”border:0;” will prevent IE9 and earlier from displaying a border around the image
How do you bookmark / link to a certain place inside a HTML document from inside the page?
~create a link to your bookmark< a href=”#tips” >Go to the Tips Section< / a >-mark the target section with an ID< a id=”tips” >Tips Section< / a >
How do you bookmark / link to a certain place inside a HTML document from another page?
~create a link to your bookmark< a href=”http://www.thispage.com/page01.htm#tips” >Visit the Tips Section< / a >-mark the target section with an ID< a id=”tips” >Tips Section< / a >
How do screen readers work? (3)
~reproduce HTML as text-to-speech, sound icons or braille output-they read alt attributes-alt attributes should accurately describe the image they represent
What are the 2 ways to specify width and height of an image?
CSS in tag styling:style=”width:128px;height:128px”HTML width & height attributes:< img width=”128” height=”128” >
What is the benefit of using CSS in tag styling for height and width instead of HTML attributes?
~prevents internal or external style sheets to change the default size of an image
How do you access an image in a sub-folder?
< img src=”/images/smilie.gif” >
How do you access an image from an image server?
~you enter the URL, the pertinent sub-folders and the file name< img src=”http://www.mouse.co.jp/mickey_and_minnie/mickey.gif” >
How do you create an image map?
< img src=”planets.jpg” alt=”Planets” usemap=”#planetmap” style=”width:145px;height:126px;” >< map name=”planetmap” >< area shape=”rect” coords=”0,0,82,126” alt=”sun” href=”sun.htm” >< area shape=”circle” coords=”90,58,3” alt=”Mercury” href=”mercury.htm” >< / map >
How can I let an image float around text / a paragraph?
~you can only use CSS, the align attribute is not supported anymore in HTML5< img src=”true” alt=”true” style=”float: left;” >-the image floats to the left of the text
Tables are defined with the … tag.
< table >…< / table >
Tables are divided into table rows with the … tag.
< tr >…< / tr >
Table columns are achieved by dividing table rows into table data with the … tag. The first row’s columns are usually reserved for the table headings, so in the first row … is replaced by the … tag.
< td > tag, < td >, < th >
How do you specify a border for a table in HTML, without using CSS?
~place the border attribute within the table tag < table border=”1” style=”width:100%” >-use style sheets instead, the border attribute is on its way to deprecation
How do you use CSS to draw a simple border around your table?
table, th, td { border: 1px solid black;}
If you want to display table borders without inner margins between the table rows and cells, how would you achieve this best?
table, th, td { border-collapse: collapse;}
Cell padding specifies the space between the … and … The default is displayed … padding.
cell content, its borders, without
How do you set a cell padding of 5 pixel?
th, td { padding: 5px;}
By default, all major browsers display table headings as … and …Which CSS property helps you to left-align the table headings?
bold, centered.th { text-align: left;}
To increase the space between cells of a table, you can use the following property…
table { border-spacing: 5px;}-does not work, if you used border collapse as well
If you have a table with 3 headlines (3 columns) and if you wanted to merge headline 1 and 2 to span two columns, how would you do it?
< tr > < th colspan=”2” >Name< / th > < th >Age< / th >< / tr >
If you want a table cell to span 2 rows, how would you do it?
< tr > < th rowspan=”2” >Animals:< / th > < td >Tiger< / td >< / tr >< tr > < td >Rhinoceros< / td >< / tr >
How do you specify an overall headline for your table?
< caption >Title of Table< / caption > -the caption tag follows immidiately after the table tag
If you use internal style sheets to format your table, consider that all tables in a document will be formatted the same way. To style a table individually, use the following…
table#IndivBunnyTable { width: 100%; background-color: blue;}< table id=”IndivBunnyTable” >
Using style sheets, how could you achieve an alternating background colour pattern (every other row is light gray) for your table.
table#01 tr:nth-child(even) { background-color: #eee;}table#01 tr:nth-child(odd) { background-color: #fff;}
How can you apply a specific type of formatting to a group of one or more columns, instead of repeating the styles for each cell, for each row? (4)
~use the < colgroup > element-it mirrors the table, but only its columns: < colgroup >< col >< col >..< / colgroup >-< col > is an empty element-must be located after < table > and < caption >, but before all others
Write up a simple colgroup for a table with 3 columns, the second and the third column are both green.
< colgroup > < col > < col span=”2” style=”background- color:green >< / colgroup > -Note: You have to declare only one of the spanned columns
< thead > is used to …
…group header content in a table.
< tbody > is used to …
…group body content in a table.
< tfoot > is used to …
…group footer content in a table.
What are the benefits of using < tbody >, < thead > or < tfoot > in a table? (4)
-used to group and structure content in a table-those 3 elements can then be formatted using style sheets-you could e.g. enable scrolling only for the body section of a table-when printing large tables across multiple pages, header and footer can be print
How do you use thead, tbody and tfoot? (3)
~the elements should frame the rows and tabledata they are supposed to encompass-thead comes after table, caption and colgroup elements, but before all other-tfoot comes after table, caption, colgroup, thead, but before tbody
What types of HTML lists exist?
~unordered lists-ordered lists-description lists
Make an unordered list with the items of coffee, chocolate and milkshake.
< ul > < li >Coffee< / li > < li >Chocolate< / li > < li >Milkshake< / li >< / ul >
How do you change the bullet type of an unordered list? What types of bullets exist?
< ul style=”list-style-type:circle” >-disc, circle, square, none
Which bullet type is used as default in an unordered list?
~round bullet / disc
Make an ordered list with the items of cinnamon, blue cheese and mango.
< ol > < li >Cinnamon< / li > < li >Blue cheese< / li > < li >Mango< / li >< / ol >
You use … to format the marker of an ordered list and … to format the bullets of an unordered list.
the HTML type attributestyle sheets
How do you change the marker type of an ordered list? What types of markers exist?
< ol type=”A” >< / ol > 1 (numbers, default), A (uppercase letters), a (lowercase letters), I (uppercase Roman numbers) and i (lowercase Roman numbers)
A HTML description list is …
… a special type of structured list, where a term is introduced and its description follows in the next line with indentation.
Make a HTML description list with the followering content:national colours - green and yellowAborigines - longest continuing culture on Earth
< dl > < dt >national colours< / dt > < dd >- green and yellow< / dd > < dt >Aborigines< / dt > < dd >- longest continuing culture on Earth< / dd >< / dl >
Tweak the following code so the list becomes displayed horizontally.< ul > < li >mermaid< / li > < li >unicorn< / li > < li >harpye< / li >< / ul >
ul#fantasy li { display:inline;}
Most HTML elements are divided into … and … elements. The former will be automatically formatted with a linebreak before and after it, the latter has no inherent formatting. Both are like containers: … for text, … for other elements.
block levelinlineinline elementsblock level elements
Which ones of these are block level elements?a) < p >b) < a >c) < b >d) < div >e) < blockquote >
a), d) and e)
Which ones of these are inline elements?a) < img >b) < ul >c) < span >d) < h2 >e) < td >
a), c) and e)
Style the background of the following text black, the text colour white.< h2 >London< / h2 >< p >London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.< / p >
< div style=”background-color: black; color: white; margin: 20px; padding: 20px;” >< / div >
Colour the background of “long tusks” blue. The gigantic mammoth has long tusks.
The gigantic mammoth has < span style=”background-colour: red;” >long tusks< / span >.
Classing HTML elements means…
…grouping elements by the attribute class to assign similar formatting to the whole group.
Assign a class to the following text and change it’s background colour to orange.My Neighbour TotoroTotoro are basically 3 fantasy animals, that look like a mix of a cat and a tanuki. There is a large one, a medium-sized one and a tiny white one.
.totoro { background-color:orange;} < div class=”totoro” >< h2 >My Neighbour Totoro< / h2 >< p >Totoro are basically 3 fantasy animals, that look like…< / p >< / div >
Use a class attribute to style all instances of the word “red” occurring in the text red.During WWI thousands of soldiers died on the battlefields of Flanders. Strikingly, a sea of red poppies grew across the burial grounds. That is why the red poppy became the symbol of Armistice Day.
span.red {color:red;}During WWI thousands of soldiers died on the battlefields of Flanders. Strikingly, a sea of < span class=”red” >red< / span > poppies grew across the burial grounds. That is why the < span class=”red” >red< / span > poppy became the symbol of Armistice Day.
Could you use the table element to design a layout?
You could and many developers have done so, because table elements can be easily styled through CSS. But remember < table > was not designed for that purpose, use < div > instead.
HTML5 has 8 new elements, especially invented to make designing layouts easier. What are they?
header - nav - footer - section - article - aside - details - summary
What does the < header > element stand for? (3)
~defines a header for a document or a section-usually reserved for the logo, banner, heading elements, etc.-new in HTML5, all latest browsers
What does the < nav > element stand for? (4)
-defines a container for navigation links-reserved for the navigation bar alone-in the past, it was a column to the left, nowadays, it’s often a horizontal bar below the banner-new in HTML5, all latest browsers
What does the < section > element stand for? (4)
~defines a section in a document-nowadays, pages are often complex: this would be reserved for structuring content into sections, chapters, headers, footers, etc.-on a simple traditional website it wud be the main body content of the page-new in HTML5, all latest browsers
What does the < article > element stand for? (3)
~defines an independent self-contained article, independent from rest of page -its the container of a self-contained topic on the same page: a forum post, a blog post, a news story or a comment-new in HTML5, all latest browsers
What does the < aside > element stand for? (4)
~defines content aside from the content it is placed in-could be a sidebar or further information about an article, etc.-must always be related to the surrounding content-new in HTML5, all latest browsers
What does the < footer > element stand for? (3)
-defines a footer for a document or a section-very commonly it’s a bar right across the bottom of the page with authorship, copyright and contact information, sitemap, back to top links, related documents, etc.-new in HTML5, all the later version browser