Professional Documents
Culture Documents
Documento 2 de HTML5
Documento 2 de HTML5
1 de 8
http://classroom.w3devcampus.com/mod/book/tool/print/index.php?id=...
1
2
3
4
5
6
<time datetime="1905-11">
November 1905
2 de 8
http://classroom.w3devcampus.com/mod/book/tool/print/index.php?id=...
<time datetime="11-13">
<time datetime="1905-W21">
<time datetime="1905-11-13
09:00">
<time
datetime="1905-11-13T09:00">
Same as previous example, both syntaxes are supported, with and without the
"T" between date and time.
<time datetime="09:00Z">
<time datetime="09:00-05">
<time datetime="09:00+05:45">
9:00 in the morning, GMT plus 5 hours 45 minutes, (like in Nepal that has 5:45
of difference with GMT)
Duration values
Duration values uses the prefix P for period as in <time datetime="P4D"> (period = four days)...
So you start the attribute string value with a "P", followed by a duration value that ends with another letter indicating the
unit used, like "D" for "days", H for hours, M for minutes and S for seconds.
You can separate the different elements "P", value and unit with spaces, but this is optional. So <time datetime="P4D"> is
a duration of 4 days, as is <time datetime="P 4 D">.
Using a T after the P marker allows you to indicate a more accurate duration time: <time datetime="PT4H 6M
12.55S"> is a duration of 4 hours, 6 minutes and 12.55 seconds.
Alternatively, you could use also a duration time component.
From Bruce Lawson's article : "Whichever you choose, its represented internally as a number of seconds. Because of this,
you cant specify a duration in terms of months, because a month isnt a precise number of seconds; a month can last from
28 to 31 days. Similarly, a year isnt a precise number of seconds; its 12 months and February sometimes has an extra day.
You still cant represent dates before the Christian era, as years cant be negative. Neither can you indicate date ranges. To
mark up From 21/02/2012 to 25/02/2012, use two separate <time> elements."
Examples :
1
2
3
4
5
3 de 8
http://classroom.w3devcampus.com/mod/book/tool/print/index.php?id=...
<time>2011-11</time>
<time>2011-11-12</time>
<time>14:54:39</time>
<time>2011-11-12 14:54:39</time>
<time>2011-W46</time>
<time>PT4H18M3S</time>
Above: examples of <details> and <summary> elements taken from the W3C specification page.
Introduction
These elements have been introduced for displaying a foldable zone in a HTML document.
The <details> element generates a simple no-JavaScript widget to show/hide element contents, optionally by clicking
on its child <summary> element.
Here is an example of what can be done using these elements: http://jsbin.com/ifofib/3/edit
And here is what is displayed after clicking on the small arrow-shaped icon to the left of the summary:
4 de 8
http://classroom.w3devcampus.com/mod/book/tool/print/index.php?id=...
1
2
3
4
5
6
7
8
9
10
5 de 8
http://classroom.w3devcampus.com/mod/book/tool/print/index.php?id=...
1
2
3
4
5
6
7
8
9
10
11
The color and background of the icon on the left is specified by the following CSS rule, which uses the pseudo
class ::-webkit-details-marker
In this example: red arrow, white background.
1
2
3
4
summary::-webkit-details-marker {
color:#FF0000;
background:#FFFFFF;
}
6 de 8
http://classroom.w3devcampus.com/mod/book/tool/print/index.php?id=...
Because the open attribute is added and removed automatically as the user interacts with the control, it can
be used in CSS to style the element differently based on its state.
Once opened, the selector details [open] can style the icon when <details> is unfolded. In this example: blue
arrow, turquoise background.
1
2
3
4
details[open] summary::-webkit-details-marker {
color:#0000FF;
background:#00FFFF;
}
It is also possible to change the icon itself using the pseudo class :after
Example 2: http://jsbin.com/ifofib/8/edit
EDIT : as 18 of March 2013, this example only worked with Chrome < version 25. It stopped working with
version 25. We are investigating and will keep you informed. Michel Buffa.
summary:after {
content: "+";
color: #FF00FF;
float: left;
font-size: 1.5em;
font-weight: bold;
margin: -5px 5px 0 0;
padding: 0;
text-align: center;
width: 20px;
}
details[open] summary:after {
content: "-";
color: #FFFFFF
}
Current support
7 de 8
http://classroom.w3devcampus.com/mod/book/tool/print/index.php?id=...
1
2
3
4
5
6
7
8
9
10
The <mark> element can be used within other tags, such as in a <pre>, a <code>, or a <b>, like in this
example: http://jsbin.com/udocog/4/edit
8 de 8
1
2
3
4
5
6
http://classroom.w3devcampus.com/mod/book/tool/print/index.php?id=...
mark {
background-color: green;
color: yellow;
}