-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblog-on-css.html
240 lines (231 loc) · 12.4 KB
/
blog-on-css.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="keywords" content="CSS, Blog, technical, Supriya, Web developer">
<meta name="description" content="Introduction to CSS">
<meta name="author" content="Supriya">
<meta name="Copyright" content="SupTECH">
<title>Supminn | Projects</title>
<link rel="icon" href="images/favicon.png" type="image/png" sizes="16x16">
<link href="styles/stylesheet.css" rel="stylesheet" />
<link href="styles/blog-styles.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
</head>
<body>
<nav class="navigation container">
<div class="nav-brand">SupTECH</div>
<ul class="list-non-bullet nav-pills">
<li class="list-item-inline">
<a class="link" href="/">Home</a>
</li>
<li class="list-item-inline">
<a class="link" href="/projects.html">Projects</a>
</li>
<li class="list-item-inline">
<a class="link link-active" href="/blogs.html">Blogs</a>
</li>
</ul>
</nav>
<header class="hero">
<img class="hero-img" src="images/html-css-js.svg" />
<h1 class="hero-heading">Beautify with <span class="heading-inverted">CSS</span></h1>
</header>
<section class="blog-section container-center">
<small>Created on: 4th December 2020</small>
<p>If you have read through my previous blog on <a class="web-link" href="blog-on-html.html">Beginning with
HTML</a>, you would have a basic understanding on how to create a simple webpage. However, it lacks the
design, styling or colors. To be honest, everything looks like a black and white document without a proper
alignment or format. This blog would help you achieve all of aforementioned with the help of CSS.</p>
</section>
<section class="blog-section container-center off-white">
<h2 class="quote">What is CSS?</h2>
<p>CSS stands for <strong>Cascading Style Sheet</strong>. Where HTML is what defines the structure and content
of a web page, a Cascading Style Sheet is a web document that allows you to change the appearance of the
HTML.</p>
<p>CSS allows you to change the size, style, font, and color of text; margins and padding; background colors and
border styles. It can also be used to position elements on a page (but we’ll leave that for another day).
</p>
<p>The best thing about CSS is that it allows you to make <i>global style changes</i> that affect every instance
of a certain element throughout your blog or website so that you don’t have to make these changes at the
individual page level. This saves you a ton of time when it comes to redesigning your blog.</p>
<p>To make it simpler, the h1 (heading 1) tag within the HTML is displayed as extra large, bold, black text. If
we want to change the color, font and size of all the h1’s on our blog to keep consistency throughout, all
you need to do is define what <u>all h1’s</u> will look like in your CSS.</p>
<p>Sometimes different browsers may display slightly different default styles. Using a style sheet to define
what a specific element should look like can keep the look of your blog consistent from one browser to
another as well as one device to another.</p>
</section>
<section class="blog-section container-center ">
<h2 class="quote">How does it work?</h2>
<p>A very important piece of CSS is the <strong>“Cascading”</strong> part. The browser reads style definitions
from top to bottom in a style sheet. This means that a style you define lower in the style sheet will
override any previous styles defined earlier in the style sheet. We’ll get into that in a moment. You can
also have a style sheet override another style sheet. There are certain defualt styles applied for specific
tags by the browser and this is how we are able to override predefined styles from our webpage, as our
custom style sheet is usually the last one read by the browser.</p>
<p>There are three different ways to implement CSS on a webpage</p>
<ul>
<li><strong>Internal CSS</strong></li>
<p>Internal or embedded CSS requires you to add <<span>style</span>> tag in the <<span>head</span>> section
of your HTML document. This CSS style is an effective method of styling a single page. However,
using this style for multiple pages is time-consuming as you need to put CSS rules to every page
of your website.</p>
<p>Here's how you can use Internal CSS</p>
<code>
<<span>!DOCTYPE html</span>>
</br>
<<span>html</span>>
</br>
<<span>head</span>>
</br>
<<span>title</span>>Page Title<<span>/title</span>>
</br>
<<span>style</span>>
</br>
body { </br>
background-color: blue; </br>
} </br>
h1 { </br>
color: red; </br>
padding: 60px; </br>
} </br>
<<span>/style</span>>
</br>
<<span>/head</span>>
</br>
<<span>body</span>>
</br>
<<span>h1</span>>This is a heading.<<span>/h1</span>>
</br>
<<span>p</span>>This is a paragraph.<<span>/p</span>>
</br>
<<span>/body</span>>
</br>
<<span>/html</span>>
</code>
</ul>
</section>
<section class="blog-section container-center off-white">
<ul>
<li><strong>External CSS</strong></li>
<p>With external CSS, you’ll link your web pages to an external .css file, which can be created by any text
editor in your device (e.g., Notepad++, VSCode).This CSS type is a more efficient method, especially for
styling a large website. By editing one .css file, you can change your entire site at once.</p>
<p>Follow these steps to use external CSS:</p>
<ol>
<li>Create a new .css file with the text editor, and add the style rules. For example:</li>
<code>
body { </br>
background-color: blue; </br>
} </br>
h1 { </br>
color: red; </br>
padding: 60px; </br>
} </code>
<li>In the <<span>head</span>> section of your HTML sheet, add a reference to your external .css file right
after <<span>title</span>>tag:</li>
<code><<span>link rel="stylesheet" type="text/css" href="style.css" /></span></code>
</ol>
<p>Don’t forget to change style.css with the name of your <i>.css</i> file.</p>
</ul>
</section>
<section class="blog-section container-center">
<ul>
<li><strong>Inline CSS</strong></li>
<p>Inline CSS is used to style a specific HTML element. For this CSS style, you’ll only need to add the style attribute to each HTML tag, without using selectors. This CSS type is not really recommended, as each HTML tag needs to be styled individually. Managing your website may become too hard if you only use inline CSS.</p>
<p>However, inline CSS in HTML can be useful in some situations. For example, in cases where you don’t have access to CSS files or need to apply styles for a single element only.</p>
<p>Let’s take a look at an example. Here, we add an inline CSS to the <<span>p</span>> and <<span>h1</span>> tag:</p>
<code>
<<span>!DOCTYPE html</span>>
</br>
<<span>html</span>>
</br>
<<span>head</span>>
</br>
<<span>title</span>>Page Title<<span>/title</span>>
</br>
<<span>/head</span>>
</br>
<<span>body</span>>
</br>
<<span>h1 style="color:white;padding:30px;"</span>>This is a heading.<<span>/h1</span>>
</br>
<<span>p style="color:white;"</span>>This is a paragraph.<<span>/p</span>>
</br>
<<span>/body</span>>
</br>
<<span>/html</span>>
</code>
</ul>
</section>
<section class="blog-section container-center off-white">
<h2 class="quote">How CSS gets applied?</h2>
<p>CSS is applied to HTML elements in a web page by declaring specific styles for each element. A style declaration looks like this:</p>
<code>
selector { </br>
property: value; </br>
}
</code>
<p>Let’s look at each of these pieces separately:</p>
<p>The <strong>selector</strong> is the piece of content that we want to target and style. It is either an HTML element or a Class Name. When defining an HTML element, we use the tag name without the opening and closing bracket. For example, the <i><<span>p</span>></i> (or paragraph tag) would simply be: <i>p</i></p>
<p>A Class Name always begins with a dot(.) For example, <i>.container</i></p>
<p><strong>Property</strong> and their respective values always live within curly braces:</p>
<code>
p { </br>
}
</code>
<p>Properties are predefined terms within CSS that all web browsers understand. They are things like: font-family, font-size, color, etc. A property is always followed by a colon (:)</p>
<code>
p { </br>
font-family: </br>
font-size: </br>
}
</code>
<p>The <strong>value</strong> is the particular style or variable you choose to assign to a property. A value is always followed by a semi-colon (;) For example:</p>
<code>
p { </br>
font-family: Arial;</br>
font-size: 16px;</br>
color: gray;</br>
}
</code>
<p>So the example above tells the browser that we want all of our page titles (or any element surrounded by an <p> tag) to be displayed in Arial font at 16 pixels in size and in the color gray. Pretty easy, right? </p>
</section>
<section class="blog-section container-center">
<p>Let me know what you think about this article. I Hope this provided you an introduction to CSS.</p>
<strong>Peace!</strong>
</section>
<div class="container">
<a class="link link-secondary" href="#">Scroll to the top</a>
<br><br>
</div>
<footer class="footer">
<div class="footer-header">Social media presence</div>
<ul class="social-links list-non-bullet">
<li class="list-item-inline">
<a class="link" href="https://discordapp.com/users/779740021510504448">
<i class="fab fa-discord"> Discord</i>
</a>
</li>
<li class="list-item-inline">
<a class="link" href="https://github.com/supminn">
<i class="fab fa-github"> Github </i>
</a>
</li>
<li class="list-item-inline">
<a class="link" href="https://twitter.com/supminn">
<i class="fab fa-twitter"> Twitter</i>
</a>
</li>
<li class="list-item-inline">
<a class="link" href="https://www.linkedin.com/in/supminn">
<i class="fab fa-linkedin-in"> Linkedin</i>
</a>
</li>
</ul>
<small>Copyright © 2020 SupTECH</small>
</footer>
</body>
</html>