-
Notifications
You must be signed in to change notification settings - Fork 0
/
elementos_bloco_e_linha.html
executable file
·332 lines (307 loc) · 13.8 KB
/
elementos_bloco_e_linha.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta name="keywords" content="HTML,CSS" />
<meta name="author" content="Alexandre Gomes de Lima" />
<meta charset="UTF-8">
<link href='http://fonts.googleapis.com/css?family=Inconsolata:400,700' rel='stylesheet' type='text/css' />
<link rel="stylesheet" type="text/css" href="estilos/aulas.css" />
<title>IFRN/DIATINF/Design Web: elementos de bloco e de linha</title>
</head>
<body>
<div id="tudo">
<header id="cabecalho">
<img src="imagens/logo_ifrn.png"
alt="Logotipo do IFRN"
id="logoifrn" />
<h1 class="cabecalho">
Diretoria Acadêmica de Gestão e Tecnologia da Informação
</h1>
<h2 class="cabecalho">
Disciplina de Design Web e Arquitetura da Informação
</h2>
</header>
<article id="conteudo">
<h1>Elementos em nível de bloco e em nível linha</h1>
<p>
Esta aula apresenta o conceito de blocos de conteúdo e introduz as
propriedades de estilização de blocos. Também passaremos a conhecer
as tags <span class="html">div</span> e <span class="html">span</span>, as
quais nos permitirão a construção de páginas HTML mais elaboradas.
</p>
<section>
<h2>Elementos de bloco e de linha</h2>
<p>
O modelo de formatação CSS organiza o conteúdo de uma página HTML em blocos
de conteúdo. Estes blocos são criados por elementos específicos denominados
<strong>elementos em nível de bloco</strong> tais como <span class="html">p</span> e
<span class="html">h1</span>. Já os elementos que não criam blocos de conteúdo, como
<span class="html">a</span> e <span class="html">img</span>, são chamados de
<strong>elementos em nível de linha</strong>. Visualmente, estes dois tipos de
elementos definem uma caixa que envolve o conteúdo do elemento. Observe o
exemplo a seguir:
</p>
<pre class="html">
p { background-color: pink; }
a { background-color: yellow; }
<p>
Visite nosso <a href="http://www.site.com">site</a> para obter mais informações.
</p>
</pre>
<img src="elementos_bloco_e_linha/exemplo01.png"
alt="Visualização do exemplo 1">
<p>
Um elemento de linha segue o fluxo de apresentação da linha em que se encontra inserido.
Já um elemento de bloco interrompe este fluxo, forçando a quebra de linha. Este comportamento
pode ser visualizado no próximo exemplo. Repare que o elemento de bloco
<span class="html">ul</span> realiza uma quebra de linha e encerra o bloco de conteúdo do
elemento <span class="html">p</span>.
</p>
<pre class="html">
p { background-color: pink; }
a { background-color: yellow; }
ul { background-color: aqua; }
<p>
Lorem ipsum dolor sit amet, <a href="http://www.site.com">LINK</a>
consectetur adipisicing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.
<ul>
<li>Ut enim ad minim veniam</li>
<li>quis nostrud exercitation</li>
<li>ullamco laboris nisi ut aliquip</li>
</ul>
ex ea commodo consequat. Duis aute irure dolor in reprehenderit
in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</p>
</pre>
<img src="elementos_bloco_e_linha/exemplo02.png"
alt="Visualização do exemplo 2">
<p>
Vários elementos visuais em uma página HTML definem uma caixa que envolve o conteúdo do elemento. Esta caixa segue
o modelo ilustrado na figura abaixo:
</p>
<img src="elementos_bloco_e_linha/modelo_caixa.png"
alt="Modelo de caixa CSS">
<p>
As margens (<span class="html">margin</span>) definem a espessura da separação entre caixas
adjacentes e são sempre transparentes.
A borda é um contorno que possui as propriedades espessura (<span class="html">border-width</span>),
cor (<span class="html">border-color</span>) e estilo (<span class="html">border-style</span>).
A propriedade <span class="html">padding</span> define o espaçamento entre a área de conteúdo e
a borda e, assim como a margem, é sempre transparente.
O exemplo abaixo ilustra a estilização destas quatro propriedades.
</p>
<pre class="html">
body { background-color: aqua; }
p {
<b>margin: 15px;
border-width: 5px;
border-color: black;
border-style: solid;
padding: 30px;</b>
background-color: pink;
}
<body>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
<p>
Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</body>
</pre>
<img src="elementos_bloco_e_linha/exemplo03.png"
alt="Visualização do exemplo 3">
<p>
Para cada uma das propriedades de caixa apresentadas, existem mais quatro propriedades
para estilização específica por dimensão. Por exemplo, para a margem temos
<span class="html">margin-top</span>, <span class="html">margin-bottom</span>,
<span class="html">margin-left</span> e <span class="html">margin-right</span>.
Veja o próximo exemplo:
</p>
<pre class="html">
body { background-color: aqua; }
p {
<b>margin-top: 50px;
margin-left: 30%;
border-top-width: 3px;
border-top-style: dotted;
border-bottom-width: 3px;
border-bottom-style: solid;</b>
background-color: pink;
}
<body>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</body>
</pre>
<img src="elementos_bloco_e_linha/exemplo04.png"
alt="Visualização do exemplo 4">
<p>
Também é possível a utilização da forma abreviada para estilização das quatro
dimensões. Basta declarar a propriedade em questão e utilizar espaço para separar
os valores. A ordem seguida é top, right, bottom e left (sentido horário començando
em top).
</p>
<pre class="html">
body { background-color: aqua; }
p {
<b>margin: 20px 3px 0px 20px;
border-width: 1px 3px 6px 12px;
border-style: solid dashed dotted double;</b>
background-color: pink;
}
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</pre>
<img src="elementos_bloco_e_linha/exemplo05.png"
alt="Visualização do exemplo 5">
</section>
<section>
<h2>Elementos div e span</h2>
<p>
A tag <span class="html">div</span> é um elemento em nível de bloco que não possui
significado (semântica) específico. Possui a capacidade de agrupar elementos tanto em nível
nível de linha quanto em nível de bloco. Uma <span class="html">div</span> pode, assim,
incluir outras <span class="html">div</span>s ou outros elementos de bloco.
Sua principal finalidade é a de realizar agrupamento de elementos HTML.
Anteriormente, <span class="html">div</span> era muito utilizada na
definição de regiões da página como cabeçalho, menu e rodapé:
</p>
<pre class="html">
#cabecalho {
font-size: 18px;
border-bottom-style: double;
border-bottom-width: 4px;
border-bottom-color: black;
}
#conteudo {
font-size: 16px;
margin-top: 10px 5px 10px 5px;
background-color: pink;
}
#rodape {
font-size: 12px;
border-top-style: double;
border-top-width: 4px;
border-top-color: black;
}
<body>
<b><div id="cabecalho">
<h1>DIATINF</h1>
</div>
<div id="conteudo">
<p>
A Diretoria Acadêmica de Gestão e Tecnologia da Informação (DIATINF)
oferta cursos técnicos integrados e cursos superiores de tecnologias.
A DIATINF também organiza os procedimentos administrativos que envolvam
alunos e professores, como registro acadêmico, elaboração de horários e
coordenação das aulas nos laboratórios.
</p>
</div>
<div id="rodape">
<p>
IFRN - Campus Natal Central <br/>
Av. Sen Salgado Filho, 1559, Tirol. Natal - RN
</p>
</div></b>
</body>
</pre>
<img src="elementos_bloco_e_linha/exemplo06.png"
alt="Visualização do exemplo 6">
<p>
Atualmente, o uso de <span class="html">div</span> não é mais recomendado para a
defnição de áreas como cabeçalho, corpo de conteúdo e navegação pois a HTML já prevê
tags específicas para isso. A orientação é que a tag <span class="html">div</span>
seja utilizada quando houver a necessidade de realizar agrupamento de elementos,
mas este agrupamento não reflete a semântica de alguma tag mais específica como
<span class="html">p</span> ou <span class="html">article</span>.
</p>
<p>
A tag <span class="html">span</span> é um elemento em nível de linha capaz de
agrupar outros elementos de linha. Geralmente este agrupamento é realizado para aplicação
de formatação específica ou para o compartilhamento de valores de atributos
(e.g., <span class="html">lang</span>). Assim como na tag <span class="html">div</span>,
o uso de <span class="html">span</span> somente é recomendado quando não houver outra
tag em nível de linha mais específica como <span class="html">strong</span> ou
<span class="html">em</span>. A seguir é apresentado um exemplo de uso de <span class="html">span</span>
para aplicação de formatação específica.
</p>
<pre class="html">
.codigo {
font-family: monospace;
}
.valor {
font-family: Arial;
font-style: italic;
}
.obs {
font-weight: bold;
color: red;
}
<p>
A propriedade <b><span class="codigo">border-style</span></b> também aceita os valores
<b><span class="valor">groove</span></b>, <b><span class="valor">ridge</span></b>,
<b><span class="valor">inset</span></b> e <b><span class="valor">outset</span></b>.
<br/>
<b><span class="obs">ATENÇÃO: </span></b> o IE 6 não segue o comportamento padrão
para estas opções de borda.
</p>
</pre>
<img src="elementos_bloco_e_linha/exemplo07.png"
alt="Visualização do exemplo 7">
</section>
<section>
<h2 class="referencias">Exercícios</h2>
<p>
1) Escreva o código HTML para gerar a página a seguir. Utilize tags <span class="html">h1</span>,
<span class="html">h2</span> e <span class="html">h3</span> e as regras
<span class="html">margin:0px</span>, <span class="html">border-width:10px</span> e
<span class="html">padding:10px</span>.
</p>
<img src="elementos_bloco_e_linha/exercicio01.png"
alt="Visualização do exercício 1">
<p>
2) Escreva o código HTML para gerar a página a seguir. Utilize tags <span class="html">div</span>
para realizar as divisões da página.
</p>
<img src="elementos_bloco_e_linha/exercicio02.png"
alt="Visualização do exercício 2" />
<p>
3) Escreva o código HTML para gerar a página a seguir. Utilize tags <span class="html">span</span>
para aplicar formatação diferenciada aos acordes da música.
</p>
<img src="elementos_bloco_e_linha/exercicio03.png"
alt="Visualização do exercício 3"
longdesc="http://www.cifraclub.com.br/clara-nunes/canto-das-tres-racas/">
<p style="font-size: small; font-style: italic">Fonte: www.cifraclub.com.br</p>
<p>
4) Escreva o código HTML para gerar a página a seguir. Utilize tags <span class="html">span</span>
para aplicar formatação diferenciada nos trechos apontados pelas setas.
</p>
<img src="elementos_bloco_e_linha/exercicio04.png"
alt="Visualização do exercício 4">
</section>
<section>
<h2 class="referencias">Referências</h2>
<ul>
<li class="referencia">
SILVA, Maurício Samy. <em class="referencia">Construindo sites com CSS e (X)HTML: sites controlados
por folhas de estilo em cascata</em>. São Paulo: Novatec, 2008.
</li>
<li>
MACEDO, Marcelo da Silva. <em class="referencia">Construindo sites adotando padrões
Web</em>. Rio de Janeiro: Ciência Moderna, 2004.
</li>
</ul>
</section>
</article>
</div>
</body>
</html>