82 |
83 | Grouping content
84 | Elements: <p>
, <address>
, <hr>
, <pre>
, <blockquote>
, <ol>
, <ul>
, <li>
, <dl>
, <dt>
, <dd>
, <figure>
, <figcaption>
, <main>
, <div>
85 |
86 |
87 |
88 |
91 |
92 | Paragraphs are usually represented in visual media as blocks of text separated from adjacent blocks by blank lines and/or first-line indentation, but HTML paragraphs can be any structural grouping of related content, such as images or form fields. [1]
93 |
94 |
95 |
96 |
99 |
100 |
101 | Name: Alexander Sandberg
102 | Street adress: 1 Rover street
103 | State: N/A
104 | Planet: Mars
105 | Digital home: alexandersandberg.com
106 |
107 |
108 |
109 |
110 |
113 |
114 |
115 |
116 |
117 |
118 |
121 |
122 | Preformatted text
123 | will be presented
124 | exactly as written
125 | in the HTML file.
126 |
127 |
128 |
129 |
130 |
131 | <blockquote>
:
132 |
133 |
134 |
135 | The text inside this blockquote is wrapped in <p>
tags. Sometimes the quote is really long, and possibly have to occupy multiple lines, but that shouldn't be a problem.
136 |
137 |
138 |
139 |
140 |
141 | <ol> + <ul> + <li>
:
142 |
143 |
144 |
145 | - List item 1
146 | - List item 2
147 |
148 | - List item 1
149 |
150 |
151 | - List item 3
152 |
153 | - List item 1
154 | - List item 2
155 |
156 | - List item 1
157 |
158 | - List item 1
159 | - List item 2
160 |
161 |
162 | - List item 2
163 |
164 |
165 | - List item 3
166 |
167 |
168 | - List item 4
169 |
170 |
171 | - List item 1
172 |
173 | - List item 1
174 |
177 |
178 | - List item 2
179 |
180 |
181 | - List item 2
182 | - List item 3
183 |
184 | - List item 1
185 | - List item 2
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 | <dl> + <dt> + <dd>
:
194 |
195 |
196 |
197 | - This is a term
198 | - And this is the accompanying description, explaining the above term.
199 | - You can also have multiple descriptions (
<dt>
), like this one, for each term (<dt>
).
200 | - And why not nest lists inside this description?
201 |
202 | - Another term
203 | - With some description.
204 |
205 |
208 |
209 | - List item 1
210 | - List item 2
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 | <figure> + <figcaption>
:
219 |
220 |
221 | Used with an <img>
:
222 |
223 |
224 | Wholesome Keanu Reeves from placekeanu.com.
225 |
226 |
227 | Used with a <blockquote>
:
228 |
229 |
230 | Seek wealth, not money or status. Wealth is having assets that earn while you sleep. Money is how we transfer time and wealth. Status is your place in the social hierarchy.
231 |
232 |
233 |
234 | Naval Ravikant (@naval) on Twitter.
235 |
236 |
237 |
238 |
239 |
240 |
243 |
244 | See the main content of this page for a use case of <main>
.
245 |
246 |
247 |
248 |
251 |
252 |
253 |
This paragraph of text is contained inside a <div>
. The element really has no special meaning, other than grouping content together, and should be used as a last resort when no other element is suitable.
254 |
255 |
256 |
257 |
260 |
261 |
262 |
263 |
264 | Text-level semantics
265 | Elements: <a>
, <em>
, <strong>
, <small>
, <s>
, <cite>
, <q>
, <dfn>
, <abbr>
, <ruby>
, <rb>
, <rt>
, <rtc>
, <rp>
, <data>
, <time>
, <code>
, <var>
, <samp>
, <kbd>
, <sub>
, <sup>
, <i>
, <b>
, <u>
, <mark>
, <bdi>
, <bdo>
, <span>
, <br>
, <wbr>
266 |
267 |
268 |
269 |
272 |
273 | Here is a link inside a paragraph of text. Below you can find a list of links with different href
attributes.
274 |
280 |
281 |
282 |
283 |
284 | <em> + <i> + <strong> + <b>
:
285 |
286 |
287 | The <em>
element represents stress emphasis of its contents. Meanwhile, <i>
is since HTML5 used for text in an alternative voice or mood, or otherwise offset from the normal prose, as you may define it.
288 | If you want to draw attention to some text, feel free to use <b>
. However, if you want to mark the importance of something, you should use <strong>
.
289 |
290 |
291 |
292 |
293 | <small> + <u> + <mark> + <s>
:
294 |
295 |
296 | When you want your text to represent small print, use <small>
.
297 | In most cases, there's a better element than <u>
to use, but it can be useful for labelling msispelt text. Avoid using it, however, where the text could be confused for a hyperlink.
298 | You can highlight text for reference purposes with <mark>
, or if the contents is no longer accurate or relevant, wrap it with <s>
.
299 |
300 |
301 |
302 |
303 | <abbr> + <dfn>
:
304 |
305 |
306 | By wrapping an abbreviation like CSS in both <dfn>
and <abbr>
, we define the term. This can later be used only using <abbr>
, since we already defined CSS once before.
307 |
308 |
309 |
310 |
311 | <q> + <cite> + <data> + <time>
:
312 |
313 |
314 | When citing creative work, include the reference with a <cite>
element. www.w3.org explains that A citation is not a quote (for which the <q>
element is appropriate)
instead, like used here.
315 | If you want to link content with a machine-readable translation, use <data>
with a value
attribute. However, if this data is a time- or date-related, like the date , you have to use <time>
together with the datatime
attribute.
316 |
317 |
318 |
319 |
320 | <code> + <var> + <samp> + <kbd> + <sub> + <sup>
:
321 |
322 |
323 | When sharing code-snippets, make sure to use the <code>
element. This can be done both display: inline;
, as well as block-level:
324 | * {
325 | color: rebeccapurple;
326 | background: aliceblue;
327 | }
328 | Variables should be surrounded by <var>
, or x amount of people might be confused.
329 | Sample or quotes output are represented with <samp>
: Your expression '1 + 1' equals 2.
330 | To represent user input, like the shortcut Cmd + R on macOS, use <kbd>
.
331 | If you want to subscript or superscript text, use <sub>
or <sup>
.
332 |
333 |
334 |
335 |
336 | <bdi> + <bdo> + <ruby> + <rb> + <rt> + <rtc> + <rp>
:
337 |
338 |
339 | Consider using <bdi>
when working with bidirectional content, like the names Alexander and علي.
340 | If you need to override the bidirectional algorithm for some content and its children, use <bdo>
:
341 | Don't forget to specify the dir
attribute!
342 | I said, don't forget to specify the dir
attribute!
343 | Some use of <ruby>
and its related elements:
344 |
345 | 漢
346 | 字
347 |
348 |
349 | 旧金山
350 | More information about the explanation and usage of these can be read here on www.w3.org.
351 |
352 |
353 |
354 |
355 | <span> + <br> + <wbr>
:
356 |
357 |
358 | A <span>
can be used to mark up inline text for various uses, here to make the text bolder.
359 | If you have really long text you might want to insert a
blank line with the <br>
element. You can also insert word breaking opportunities using <wbr>
, to help the browser break long words like Pneumonoultramicroscopicsilicovolcanoconiosis.
360 |
361 |
362 |
363 |
366 |
367 |
368 |
390 |
391 | Embedded content
392 | Elements: <picture>
, <source>
, <img>
, <iframe>
, <embed>
, <object>
, <param>
, <video>
, <audio>
, <track>
, <map>
, <area>
, <math>
, <svg>
393 |
394 |
395 |
396 |
397 | <img> + <svg>
:
398 |
399 |
400 |
401 |
405 |
406 |
407 |
408 |
409 | <picture> + <source>
:
410 |
411 |
412 | A different image will be shown depending on viewport size.
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
423 |
424 |
425 |
426 |
427 |
428 |
431 |
432 |
434 |
435 |
436 |
437 | <object> + <param>
:
438 |
439 |
440 |
443 |
444 |
445 |
446 |
447 | <video> + <audio> + <track>
:
448 |
449 |
450 |
453 | Audio is from an example on MDN.
454 |
459 | Video and subtitles are from an example on MDN.
460 |
461 |
462 |
463 |
464 | <map> + <area>
:
465 |
466 |
467 | Each side of the image below is linked to different anchors on this page. Give it a try!
468 |
472 |
473 |
474 |
475 |
476 |
479 |
480 | The quadratic formula is:
481 |
499 |
500 |
501 |
502 |
505 |
506 |
507 |