-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCSS_notes.txt
591 lines (429 loc) · 10 KB
/
CSS_notes.txt
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
CSS :
(Cascading style sheet)
USing css we apply styles in HTML. only CSS useful for
applying syles in HTML. CSS code we always embedded in HTML.
Advantage of CSS:
----------------------------
--code reusability
--css saves our time
--Easy to maintain the code
--css javscript,vbscript ,Angular, React(Compatability)
--Using CSS we apply mutiple properties(background, text, border, image)
syntax Of CSS:
----------------
selector{property: value}
h1{color:red}
---declaration---
OR
selector{property1: value1,property2: value2,property3:value3.......}
h1{color:red, size: 12px, background-color:red}
h1
{
color:red;
background-color:yellow;
}
Selectors in CSS:
------------------------
selector it is one of the tag name or element for applying styles
mainly 3 types of selectors
1. class selector
2. id selector
3. mutiple selector
How we embedded css in html is we use one of the main tag i.e
<style>
</style>
here style tag it has some ofthe attributes. that attribute is type
<style type="text/css">
</style>
1. class Selectors:
-------------------------
in css class selector follows with class attribute and there value.
whenever we add styles in style tag, we should starts with '.' dot
operator with attribute value.
<html>
<head>
<style type="text/css">
.first
{
color:red;
text-align:center;
}
.second
{
color:blue;
text-align:center;
}
</style>
</head>
<body>
<p class="first">Hello World</p>
<h1 class="second">Heading tag in html</h1>
</body>
</html>
2. Id selectors:
--------------------------------
in css id selector must follows one of the attribute in tag name or element name
declaration--- i.e id attribute , and for adding id selector
styles then it start with # symbol character.
<html>
<head>
<style type="text/css">
#first
{
color:red;
text-align:center;
background-color:yellow;
}
#second
{
color:blue;
text-align:center;
}
</style>
</head>
<body>
<p id="first">Hello World</p>
<h1 id="second">Heading tag in html</h1>
</body>
</html>
3. Group Selectors:
--------------------------------------------------------
<html>
<head>
<style type="text/css">
.one
{
text-align:center;
color:red;
}
.two
{
text-align:center;
color:red;
}
.three
{
text-align:center;s
color:red;
}
</style>
</head>
<body>
<h1 class="one">Welcome to CSS program</h1>
<h2 class="two">Welcome to HTML programm</h2>
<p class="three">Welcome to javascript program</p>
</body>
</html>
group selector
===================================================
Add all tag in single then we apply styles known as group selector
<html>
<head>
<style type="text/css">
h1,h2,p
{
color:red;
}
</style>
</head>
<body>
<h1>Welcome to CSS program</h1>
<h2>Welcome to HTML programm</h2>
<p>Welcome to javascript program</p>
</body>
</html>
CSS comments:
------------------------------------------
comments simply ignored by interpreter
html, css, javscript the code which is executed by " interpreter ""
c, c++ the program 'compiler'
commenents are not executed by the interpreter.
/* comment code */
<html>
<head>
<style type="text/css">
h1,h2,p
{
/*group selectors in css*/-- comment in html
color:red;
}
</style>
</head>
<body>
<h1>Welcome to CSS program</h1>
<h2>Welcome to HTML programm</h2>
<p>Welcome to javascript program</p>
</body>
</html>
Where we include the css :
--------------------------------------
if u want to include the css code in html then u follows the
following ways.
There are 3 ways to incllude css code in html
1. external style sheet
2. Internal style sheet(Embedded style sheet)
3. inline style sheet
1. External style sheet:
---------------------------------------
With an external style sheet you can change the look of an entire
website by using just one file.
External style sheet we include from outside of the html programm.
We save the external style sheet prrogram as with .css extension.
and that should be included in html file by using
one of the tag i.e <link>
<link rel="stylesheet" type="text/css" href="mystyle.css"></link>
first.html
-----------------------------------
<html>
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css"></link>
</head>
<body>
<h1>Welcome to CSS program</h1>
<h2>Welcome to HTML programm</h2>
<p>Welcome to javascript program</p>
</body>
</html>
mystyle.css:
==========================
h1
{
color:red;
text-align:left;
}
h2
{
color:blue;
text-align: center;
}
p
{
color:yellow;
text-align: right;
}
2. Internal style sheet or Embedded style sheet:
-------------------------------------------------------------
Internal style mean adding styles in Head section in html
is known as Internal style sheet.
<html>
<head>
<style type="text/css">
h1,h2,p
{
color:red;
text-align:center;
}
</style>
</head>
<body>
<h1>Welcome to CSS program</h1>
<h2>Welcome to HTML programm</h2>
<p>Welcome to javascript program</p>
</body>
</html>
3. Inline style sheet:
-----------------------------------------
Inline style may be used to apply a unique
style for a single element.
<html>
<head>
</head>
<body>
<h1 style="color:red; text-align:center;">Welcome to CSS program</h1>
<h2 style="color:blue; text-align:center;">Welcome to HTML programm</h2>
<p style="color:green; text-align:center;">Welcome to javascript program</p>
</body>
</html>
CSS- Background:
------------------------------------------------------
The CSS background properties are used to define the background
effects for elements.
background-color
background-image
background-repeat
background-position
1. background-color:
The background-color property specified the background-color of an element.
Example:
body
{
background-color: red;
}
<html>
<head>
<style type="text/css">
body
{
background-image:url('ganesh.jpg');
}
</style>
</head>
<body>
<h1 >Welcome to CSS program</h1>
<h2 >Welcome to HTML programm</h2>
<p >Welcome to javascript program</p>
</body>
</html>
Example2:
--------------
in the below example program image file repeated in y dimension
similerly we change the value as repeat-x dimesnion or repeat
<html>
<head>
<style type="text/css">
body
{
background-image:url('ganesh.jpg');
background-repeat: repeat-y;
}
</style>
</head>
<body>
<h1 >Welcome to CSS program</h1>
<h2 >Welcome to HTML programm</h2>
<p >Welcome to javascript program</p>
</body>
</html>
CSS Border Properties:
------------------------------
In css the following are the border properties . They are
1. dotted
2.dashed
3. solid
4. double
5.groove....
<html>
<head>
<title>border properties</title>
<style type="text/css">
.one{ border-style:dotted; border-width:4px; border-color:#ff0000}
.two{ border-style:dashed; border-width:2px; border-color:#ff0000}
.three{ border-style:solid; border-width:3px; border-color:#ff0000}
.four{ border-style:double; border-width:4px; border-color:#ff0000 }
.five{ border-style:groove; border-width:5px; border-color:#ff0000}
.six{ border-style: ridge; border-width:6px; border-color:#ff0000}
</style>
</head>
<body>
<p class="one">Welcome to Border properties</p>
<p class="two">Welcome to Border properties</p>
<p class="three">Welcome to Border properties</p>
<p class="four">Welcome to Border properties</p>
<p class="five">Welcome to Border properties</p>
<p class="six">Welcome to Border properties</p>
</body>
</html>
example2:
<html>
<head>
<title>border properties</title>
<style type="text/css">
.one{ border-left:10px solid red;}
.two{ border-right:10px solid blue;}
.th{ border-bottom:10px solid green;}
.f{ border-top:10px solid cyan;}
</style>
</head>
<body>
<p class="one">Welcome to Border properties</p>
<p class="two">Welcome to Border properties</p>
<p class="th">Welcome to Border properties</p>
<p class="f">Welcome to Border properties</p>
</body>
</html>
CSS Margins:
----------------------
The Css margin prooperties are used to create
space around elements outside of any defined borders.
margin-top
margin-right
margin-bottom
margin-left
<html>
<head>
<title>border properties</title>
<style type="text/css">
p
{
margin-top:100px;
margin-left:100px;
margin-right:200px;
margin-botton:200px;
}
</style>
</head>
<body>
<p class="one">
CSS Margins:
----------------------
The Css margin prooperties are used to create
space around elements outside of any defined borders.
margin-top
margin-right
margin-bottom
margin-left
</p>
</body>
</html>
CSS Padding:
------------------------------------------------
providing space around the element
padding-top
padding-bottom
padding-left
padding-right
<html>
<head>
<style type="text/css">
.one
{
padding-top: 50px;
padding-bottom:50px;
padding-left:100px;
padding-right:30px;
}
</style>
</head>
<body>
<pre class="one">
CSS Margins:
----------------------
The Css margin prooperties are used to create
space around elements outside of any defined borders.
margin-top
margin-right
margin-bottom
margin-left
</pre>
<pre>
CSS Margins:
----------------------
The Css margin prooperties are used to create
space around elements outside of any defined borders.
margin-top
margin-right
margin-bottom
margin-left
</pre>
</body>
</html>
CSS text properties:
---------------------------
<html>
<head>
<style type="text/css">
h1{color:red;text-transform:uppercase}
h2{color:green;text-decoration:overline}
h3{color:blue;text-decoration:line-through;text-transform:capitalize}
h4{color:yellow;text-decoration:underline}
h5{color:orange;text-transform:lowercase}
</style>
</head>
<body>
<h1>Css Text properties </h1>
<h2>CSS Text align properties</h2>
<h3>css text color properties</h3>
<h4>CSS TExt decoration properties</h4>
<h5>CSS text transfomation properties</h5>
</body>
</html>