<link>
<js>
<script>
<body>
<charset>
<meta>
<html>
<!doctype>
<header>
<h1>
<meta>
<h2>
<sidebar>
<other>
<aside>
<footer>
<ol>
<nl>
<dl>
<ul>
<aside>
<legal>
<small>
<q>
role
type
name
rel
key
attr
value
name
spacing
margin
min-width
padding
boldness
font-style
font-weight
text-decoration
text-decoration
font-variant
font-style
border
content
before
after
text
font-size
font-height
height
line-height
opacity
display
position
visibility
:even-child()
:nth-child()
:first-child
:even
pt
in
ft
em
width: 100%
and width: auto
?
width: 100%
sets the content area of an element to be 100% the size of its container, while width: auto
stretches the content area out as far as it can go, minus the element's horizontal margin and padding.
display: inline; font-size: 1em;
display: inline-block;
display: inline;
file()
include()
url()
hsla()
var x = "hello";
hello
and returns the string "world".
function (hello) {
return "world";
}
true
or false
.
"2" === 2
(will evaluate to false
)
if ('yes') {
alert('uh huh');
} else if ('no') {
alert('nope');
} else {
alert('what?');
}
toInt
toString
parseInt
int
confirm
alert
prompt
choose
Because it didn't wait for the DOM to finish loading, meaning the element on line 20 doesn't yet exist
<body>
element using jQuery?
$('body')
$.get
, $.getJSON
, $.getScript
, $.ajax
, $.post
, load
fadeIn
Most functions on this page. The best one to use is on
.
"1"
?
function() {
$('#box').css('opacity', 0);
$('#box').fadeIn();
return $('#box').css('opacity');
}
Because JavaScript is does not wait for asynchronous tasks, like fade-in animation, to complete before evaluating the next expression. It will return "0"
or something very close as the expression runs immediately after #box
has been told to fade in.
Because the server might deliver it with a Content-Type
other than text/html
.
These next questions come from an interview quiz I wrote, so they're generally harder yet cover some of the same ground.
document.createElement('elementname')
or use html5shiv (or Modernizr which comes with it)
Set them all to display: block
, or use a modern CSS reset file which does that for you
<blockquote>
ready
function?
$(function() {...});
-ms-
and -o-
background-image
, filter
<script>
tags in the <head>
, or bottom of the <body>
.
Tags in the <head>
load and execute immediately, slowing down the perceptual load time of the page, but they can prepare the DOM to render the rest of the page properly (a la html5shiv).
Tags at the bottom of the <body>
load after the HTML and CSS has all been displayed on the page, which is good because a user shouldn't interact with a page until they can see it rendered properly.
#
) in CSS files?
Because the rule can then only be used once per page, which is inflexible.
style
attribute into elements?
Because it leads to potential repetition if it's used all over the place and is difficult to easily override via stylesheets. Classes should be hard-coded instead.
Use a clearfix hack.
on
<img>
tag?
src
and alt
rgba()
<div>
and <span>
in a typical user-agent stylesheet?
<div>
has display: block
200
Don't include the protocol in the href
/src
, like "//www.google.com/"