Sebelum masuk ke cara membuat website dengan HTML dan CSS, Anda harus
menyiapkan Text Editor dan Web Browser terlebih dahulu. Text editor
digunakan sebagai tools untuk menulis kode, sedangkan web browser digunakan
untuk mengakses website.
Pada tutorial ini, kami akan menggunakan Visual Studio Code (VS Code) atau
sublime textsebagai teks editornya dan Google Chrome sebagai browsernya.
Anda bebas menggunakan tool favorit Anda.
Website yang akan Anda buat kali ini adalah website portfolio sederhana
menggunakan HTML dan CSS saja. Nantinya, tampilan website akan seperti ini
:
Kemudian, buat folder baru dengan nama images. Folder ini merupakan tempat
untuk menyimpan gambar/assets yang akan digunakan pada website.
File HTML berisi kode utama untuk membangun struktur website Anda. Ibarat
mobil, HTML di website sama seperti rangka mobil yang membentuk dan
menopang body mobil. Oleh karena itu, file ini harus dibuat terlebih dahulu.
Pada dasarnya, struktur setiap halaman HTML tersusun atas 4 bagian utama,
yaitu :
Tag DTD/Doctype : Document Type Declaration (DTD) harus ditulis
pada awal dokumen. Tag ini berfungsi untuk mendeklarasikan tipe
dokumen dan versi HTML yang digunakan untuk diproses pada web
browser.
Tag HTML : Merupakan wadah dari semua elemen html.
Tag Head : Berisi informasi website yang tidak tampil di halaman web
browser. Misalnya, source css, source js, title, meta charset.
Tag Body : Berisi semua elemen yang tampil di halaman web browser.
Disinilah bagian dimana semua konten ditulis.
Kalau begitu, cara membuat website sederhana dengan HTML bisa dimulai
dengan menambahkan kode berikut ini pada file index.html Anda :
Nah, yang perlu Anda perhatikan pada bagian head ini adalah lokasi tempat
menyimpan file CSS. Pastikan file CSS berada pada folder yang sama dengan
file HTML. Jika berbeda folder, pastikan Anda memasukkan path yang sesuai
pada bagian href.
1
<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="utf-8">
5 <title>Personal Website</title>
6 <link rel="stylesheet" type="text/css" href="style.css"/>
<script src="https://kit.fontawesome.com/c8e4d183c2.js" crossorigin="anonymous"></script>
7</head>
8
Kedua, masuk ke tag body. Bagian pertama pada body website portfolio ini
adalah tampilan awal/welcome home yang terdiri dari navigation bar, text
container, dan gambar.
Navigation bar atau biasa disebut navbar merupakan komponen utama navigasi
website yang berupa menu, biasanya terletak pada bagian header website.
Sedangkan tag class text container pada kode di bawah ini merupakan bagian
dimana Anda dapat menambahkan tulisan untuk tampilan awal website ketika
diakses.
1
2
3 <body>
4 <section>
5 <!--- navigation --->
6 <nav>
<!--- logo --->
7 <a href="#" class="logo">Portfolio Tutorial</a>
8 <!--- menu --->
9 <ul>
10 <li><a href="#" class="active">Home</a></li>
<li><a href="#">Services</a></li>
11 <li><a href="#">Testimonials</a></li>
12 <li><a href="#">Contact</a></li>
13 </ul>
14 </nav>
15
16 <!--- text --->
<div class="text-container">
17 <p>Hello,</p>
18 <p>I’M NIDA</p>
19 <p>SEO Technical Writer & Developer</p>
20 <p>An aquarius girl who loves music, watching movies and
<br>of course writing.</p>
21
<button class="hire-btn">Hire me</button>
22 <button class="down-cv">Download CV</button>
23 </div>
24 <!-- model -->
25 <img alt="model" class="model" src="images/ilustrasi.jpg">
</section>
26
27
28
Ketiga, karena ini website portfolio, Anda dapat menambahkan bagian services
atau layanan. Pada bagian ini, Anda dapat menunjukkan layanan yang dapat
Anda kerjakan dan skill apa saja yang Anda miliki. Layanan tersebut dapat
Anda tuliskan pada tag <div class="box-container">.
1
2 <div class="box-container">.
3
<!-- services/layanan -->
4 <div class="services">
5 <!--text-->
6 <div class="services-text ">
7 <p>Services</p>
8 <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
9 type specimen book. It has survived not only five centuries, but also the leap into electronic
10 </div>
11
12 <div class="box-container">
<!--- 1 --->
13 <div class="box-1">
14 <span>1</span>
15 <p class="heading">Technical Writing</p>
16 <p class="details">Lorem Ipsum is simply dummy text of the printing and typesett
17 dummy text ever since the 1500s.</p>
<button>Read More</button>
18 </div>
19 <!--- 2 --->
20 <div class="box-2">
21 <span>2</span>
22 <p class="heading">Web Design</p>
<p class="details">Lorem Ipsum is simply dummy text of the printing and typesett
23 dummy text ever since the 1500s.</p>
24 <button>Read More</button>
25 </div>
26 <!--- 3 --->
<div class="box-3">
27 <span>3</span>
28 <p class="heading">Web Development</p>
29 <p class="details">Lorem Ipsum is simply dummy text of the printing and typesett
30 dummy text ever since the 1500s.</p>
31 <button>Read More</button>
</div>
32 </div>
33 </div>
34
Keempat, jika Anda sudah pernah mengerjakan atau memiliki proyek, Anda
dapat menambahkan testimoni pada website portfolio. Bagian ini dapat Anda isi
dengan review dan rating dari klien atas hasil kerja Anda.
Jika Anda masih bingung, Anda dapat langsung melihat hasilnya dengan
menyalin keseluruhan kode berikut ini pada text editor yang Anda gunakan :
1 <!DOCTYPE html>
<html>
2
<head>
3 <meta charset="utf-8">
4 <title>Personal Website</title>
5 <link rel="stylesheet" type="text/css" href="style.css"/>
6 <script src="https://kit.fontawesome.com/c8e4d183c2.js" crossorigin="anonymous">
</head>
7
8 <body>
9 <section>
10 <!--- navigation --->
11 <nav>
12 <!--- logo --->
<a href="#" class="logo">Portfolio Tutorial</a>
13 <!--- menu --->
14 <ul>
15 <li><a href="#" class="active">Home</a></li>
16 <li><a href="#">Services</a></li>
<li><a href="#">Testimonials</a></li>
17 <li><a href="#">Contact</a></li>
18 </ul>
19 </nav>
20
21 <!--- text --->
<div class="text-container">
22
<p>Hello,</p>
23 <p>I’M NIDA</p>
24 <p>SEO Technical Writer & Developer</p>
25 <p>An aquarius girl who loves music, watching movies and
26 <br>of course writing.</p>
<button class="hire-btn">Hire me</button>
27 <button class="down-cv">Download CV</button>
28 </div>
29 <!-- model -->
30 <img alt="model" class="model" src="images/ilustrasi.jpg">
31 </section>
32
<!-- services -->
33 <div class="services">
34 <!--text-->
35 <div class="services-text ">
36 <p>Services</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting i
37 text ever since the 1500s, when an unknown printer took a galley of type and scra
38 only five centuries, but also the leap into electronic typesetting, remaining essen
39 </div>
40
41 <div class="box-container">
<!--- 1 --->
42 <div class="box-1">
43 <span>1</span>
44 <p class="heading">Technical Writing</p>
45 <p class="details">Lorem Ipsum is simply dummy text of the pri
46 industry's standard dummy text ever since the 1500s.</p>
<button>Read More</button>
47 </div>
48 <!--- 2 --->
49 <div class="box-2">
50 <span>2</span>
<p class="heading">Web Design</p>
51 <p class="details">Lorem Ipsum is simply dummy text of the pri
52 industry's standard dummy text ever since the 1500s.</p>
53 <button>Read More</button>
54 </div>
55 <!--- 3 --->
<div class="box-3">
56 <span>3</span>
57 <p class="heading">Web Development</p>
58 <p class="details">Lorem Ipsum is simply dummy text of the pri
59 industry's standard dummy text ever since the 1500s.</p>
<button>Read More</button>
60
</div>
61 </div>
62 </div>
63
64 <!--testimonials-->
<div class="testimoni">
65 <!--text-->
66 <div class="testimoni-text ">
67 <p>What Our Client Says..</p>
</div>
68
69
<div class="testimoni-col">
70 <div class="testimoni-1">
71 <img src="images/ava1.png">
72 <div>
73 <p>Lorem Ipsum is simply dummy text of the printing and typese
dummy text ever since the 1500s.</p>
74 <h3>Client Pertama</h3>
75 <i class="fas fa-star"></i>
76 <i class="fas fa-star"></i>
77 <i class="fas fa-star"></i>
78 <i class="fas fa-star"></i>
<i class="far fa-star"></i>
79 </div>
80 </div>
81
82 <div class="testimoni-2">
83 <img src="images/ava2.png">
<div>
84 <p>Lorem Ipsum is simply dummy text of the printing and typese
85 dummy text ever since the 1500s.</p>
86 <h3>Client Kedua</h3>
87 <i class="fas fa-star"></i>
88 <i class="fas fa-star"></i>
<i class="fas fa-star"></i>
89 <i class="fas fa-star"></i>
90 <i class="fas fa-star"></i>
91 </div>
92 </div>
93 </div>
</div>
94
95 <!-- footer -->
96 <footer>
97 <p>Interested In Using Our Services?</p>
98
<!--paragraph-->
99 <p>I try to work on your project as quickly as possible. Guarantee for revi
100 <!--social-->
101 <div class="social-icons">
102 <a href="#"><i class="fab fa-whatsapp"></i></a>
103 <a href="#"><i class="fab fa-facebook-f"></i></a>
<a href="#"><i class="fab fa-twitter"></i></a>
104 <a href="#"><i class="fab fa-instagram"></i></a>
105 <a href="#"><i class="fab fa-youtube"></i></a>
106 </div>
107
<!--copyright-->
108
<p class="copyright">Copyright by Niagahoster Tutorial</p>
109 </footer>
110
111 <!--social-attach-bar-->
112 <div class="social">
<a href="#"><i class="fab fa-whatsapp"></i></a>
113
114
115
116
117
118
119
120
121
122 <a href="#"><i class="fab fa-facebook-f"></i></a>
123 <a href="#"><i class="fab fa-twitter"></i></a>
<a href="#"><i class="fab fa-instagram"></i></a>
124 <a href="#"><i class="fab fa-youtube"></i></a>
125 </div>
126 </body>
127
128 </html>
129
130
131
132
133
134
135
136
137
Nah, sekarang website portfolio sederhana Anda sudah jadi. Namun, karena
belum menggunakan CSS, tampilannya masih seperti ini :
Hmm masih agak membingungkan dan kurang menarik ya, langsung saja
tambahkan CSS-nya, yuk!
Sekarang, saatnya cara membuat website dengan CSS agar tampilannya lebih
rapi dan menarik. Seperti yang sudah dibahas sebelumnya, tanpa CSS, tampilan
website hanya sebatas text saja.
Jika kembali pada analogi mobil sebelumnya, CSS di website seperti cat mobil
yang dapat diganti dan disesuaikan untuk membuat tampilan mobil terlihat lebih
keren. Meskipun rangka atau strukturnya sama, Anda dapat mengubah style
tampilan sesuai selera Anda.
Anda dapat coba menggunakan kode di bawah ini terlebih dulu sebelum
mengubahnya menggunakan style Anda sendiri :
1 @charset "utf-8";
/* CSS Document*/
2 body{
3 background-color:#ffffff;
4 margin:0px;
5 padding:0px;
6 }
7
ul{
8 list-style:none;
9 }
10
11 a{
12 text-decoration:none;
13 }
14
15 section{
width:100%;
16
height:95vh;
17 position: relative;
18 }
19
20 nav{
21 display: flex;
justify-content: space-between;
22 align-items:center;
23 height:60px;
24 background-color:#FFFFFF;
25 box-shadow:2px 2px 12px rgba(0,0,0,0.2);
26 padding:0px 5%;
27 }
28 nav ul{
29 display: flex;
30 }
31 nav ul li a{
32 margin:30px;
33 font-family:myriad pro regular;
34 color:#505050;
35 font-size: 15px;
font-weight:700;
36 }
37
38 .logo{
39 font-family:RoadTest;
40 color:#000000;
41 font-size: 22px;
font-weight: bold;
42 }
43
44 .active{
45 color:#2d2a2a;
46 font-weight:bold;
}
47
48 .text-container p:nth-child(1){
49 font-family: calibri;
50 font-weight: bold;
51 color: #6d6d6d;
52 font-size: 22px;
}
53
54 .text-container p:nth-child(2){
55 font-family: calibri;
56 font-weight: bold;
57 letter-spacing: 2px;
color: #1a1a1a;
58
font-size: 60px;
59 }
60
61 .text-container p:nth-child(3){
font-family: myriad pro regular;
62
color: #403e3e;
63 font-size: 30px;
64 line-height: 30px;
65 }
66
67 .text-container p:nth-child(4){
font-family: calibri;
68 color: #403e3e;
69 font-size: 17px;
70 margin-top: 10px;
71 line-height: 30px;
72 }
73
.text-container p{
74 line-height: 0px;
75 margin: 55px 0px 25px;
76 }
77
78 .text-container{
position: absolute;
79 left: 13%;
80 top: 42%;
81 transform: translate(-13%, -42%);
82 }
83
84 .text-container button{
width: 130px;
85 height: 42px;
86 border-radius: 10px;
87 font-family: calibri;
88 font-weight: bold;
89 font-size: 14px;
outline: none;
90 margin: 0px 10px;
91 }
92
93 .hire-btn{
94 border: 2px solid #373636;
color: #373636;
95 }
96
97 .down-cv{
98 background-color: #0b0b0b;
99 color: #ffffff;
100 border: none;
}
101
102 button:active{
103 transform: scale(1.1);
104 }
105
.model{
106 height: 560px;
position: absolute;
107
bottom: 60px;
108 left: 80%;
109 transform: translateX(-70%);
110 }
111
112 .services{
height:600px;
113 background-color:#f6f5f5;
114 padding: 2% 10% 0px 10%;
115 }
116
117 .services-text p:nth-child(1){
118 font-family: calibri;
font-weight:bold;
119 color:#1d1c1c;
120 font-size:30px;
121 line-height:0px;
122 text-align: center;
margin-bottom: 40px;
123 }
124
125 .services-text p:nth-child(2){
126 font-family:calibri;
127 color:#7e7d7d;
128
129 }
130
.services-text{
131 margin:50px 0px;
132 }
133
134 .box-container{
135 display:flex;
136 justify-content:space-between;
}
137
138 .box-1,.box-2,.box-3{
139 width: 300px;
140 height:320px;
141 background-repeat: no-repeat;
background-size: cover;
142 box-shadow:2px 2px 18px rgba(0,0,0,0.3);
143 align-items: center;
144 justify-content: center;
145 display: flex;
146 flex-direction: column;
margin: 0px 4px;
147
148 }
149
150 .box-1{
background-image:url("images/services-1.png");
151
}
152
153 .box-2{
background-image:url("images/services-2.png");
154
}
155
156 .box-3{
157 background-image: url("images/servies-3.png");
158 }
159
160 .box-1 span,
.box-2 span,
161 .box-3 span{
162 width:40px;
163 height:40px;
164 border-radius:50%;
165 background-color:#ffffff;
display: flex;
166 justify-content: center;
167 align-items:center;
168 font-family: calibri;
169 font-weight: bold;
}
170
171 .box-1 p:nth-child(2),
172 .box-2 p:nth-child(2),
173 .box-3 p:nth-child(2){
174 color:#FFFFFF;
175 font-family: calibri;
font-size: 23px;
176 line-height:0px;
177 }
178
179 .box-1 p:nth-child(3),
180 .box-2 p:nth-child(3),
181 .box-3 p:nth-child(3){
font-family: calibri;
182 color:#8F8F8F;
183 text-align:center;
184 width: 230px;
185 margin:0px 0px 20px 0px;
}
186
187 .box-1 button,
188 .box-2 button,
189 .box-3 button{
190 width:100px;
191 height:30px;
background-color:#FFFFFF;
192 border:none;
193 outline: none;
194 border-radius:5px;
195 }
196
.testimoni{
197
height:500px;
198 background-color:#FFFFFF;
padding: 2% 10% 0px 10%;
199
text-align: center;
200 margin: auto;
201 }
202
203 .testimoni-text p:nth-child(1){
204 font-family: calibri;
font-weight:bold;
205 color:#1d1c1c;
206 font-size:30px;
207 line-height:0px;
208 }
209
210 .testimoni-text{
margin:70px 0px;
211 }
212
213 .testimoni-col{
214 display:flex;
215 justify-content:space-between;
}
216
217 .testimoni-1,.testimoni-2{
218 flex-basis: 44%;
219 border-radius: 10px;
220 margin-bottom: 5%;
221 text-align: left;
background: #f4f2f4;
222 padding: 25px;
223 cursor: pointer;
224 display: flex;
225 width: 500px;
226 box-shadow: 2px 2px 12px rgba(0,0,0,0.2);
}
227
228 .testimoni-col img{
229 height: 60px;
230 margin-left: 5px;
231 margin-right: 30px;
margin-top: 20px;
232 border-radius: 50%;
233 }
234
235 .testimoni-col p{
236 padding: 0;
237 }
238
.testimoni-col h3{
239 margin-top: 15px;
240 text-align: left;
241 }
242
243 .testimoni-col .fas, .testimoni-col .far{
color: #f44336;
244 }
245
footer p{
246
font-family: calibri;
247 }
248
249 footer p:nth-child(1){
250 font-size: 30px;
251 font-weight:bold;
color:#FFFFFF;
252 line-height:10px;
253 }
254
255 footer p:nth-child(2){
256 font-size: 16px;
257 color:#7e7d7d;
width:600px;
258 text-align: center;
259 }
260
261 footer{
262 height:300px;
display: flex;
263 flex-direction: column;
264 align-items: center;
265 justify-content: center;
266 position: relative;
267 background-color: #191919;
}
268
269 .social-icons a{
270 width:40px;
271 height:40px;
272 display: flex;
273 justify-content: center;
align-items: center;
274 background-color:#e6e3e3;
275 margin:20px 10px;
276 border-radius:50%;
277 }
278
.social-icons{
279 display: flex;
280
281 }
282
283 .social-icons i,.social i{
284 color:#000000;
}
285
286 .social-icons a:hover{
287 background-color:#000000;
288 box-shadow:2px 2px 12px rgba(0,0,0,0.2);
289 transition:all ease 0.5s;
}
290
291 .social-icons a:hover i,
.social a:hover i{
292
color:#FFFFFF;
293 transition:all ease 0.5s;
294 }
295
296 .copyright{
color:#565555;
297 font-size: 15px;
298 position: absolute;
299 left:50%;
300 bottom:10px;
301 transform: translateX(-50%);
}
302 .social{
303 position: fixed;
304 top:50%;
305 right:0px;
transform:translateY(-50%);
306 }
307
308 .social a{
309 display: flex;
310 justify-content: center;
311 align-items: center;
width:50px;
312 height:50px;
313 margin:0px;
314 padding: 0px;
315 line-height:0px;
316 background-color:#FFFFFF;
border:1px solid #CBCBCB;
317 box-shadow:2px 2px 12px rgba(0,0,0,0.2);
318 }
319
320 .social a:hover{
321 background-color:#000000;
transition:all ease 0.5s;
322 }
323
324 .social i{
325 font-size:20px;
326 color:#2B2B2B;
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
Jadi, dari kode tersebut, manakah yang dimaksud dengan selektor, blok
deklarasi, properti dan nilai?
Blok deklarasi diawali dengan tanda kurung { dan diakhiri dengan tanda kurung
}.
Untuk memahami kode CSS lebih dalam, Anda dapat mencoba untuk mengubah
kode di atas dan lihat bagaimana pengaruhnya terhadap tampilan website
portfolio Anda.
Cara membuat website dengan HTML dan CSS yang efektif adalah dengan
membuka teks editor dan browser bersamaan.
Kenapa begitu?
Nah, sekarang mari coba jalankan website portfolio yang sudah Anda buat
sebelumnya!
Inilah contoh tampilan awal website dengan kode di atas. Wajar jika tampilan
website Anda agak berbeda, karena gambar/assets yang Anda gunakan juga
mungkin berbeda. Jadi sesuaikan saja, ya?
Oh ya, jangan lupa cek kalau ada gambar yang tidak muncul. Pastikan path
tempat menyimpan gambar dan tipe file image yang digunakan sudah benar.
Kesimpulan
Itulah cara membuat website dengan HTML dan CSS yang bisa Anda coba.
Sangat mudah, kan? Hanya dengan menggunakan file HTML dan CSS saja,
Anda sekarang bisa membuat website portfolio Anda sendiri.
Sayangnya, website tersebut hanya bisa diakses offline sebab semua asetnya
tersimpan di komputer Anda saja. Agar bisa dilihat banyak orang, Anda perlu
mengonline-kan dulu, ya!
Caranya, Anda memerlukan layanan web hosting untuk menyimpan aset Anda
agar bisa diakses online. Namun, jangan sembarang memilih layanan hosting
web, ya!
Selain itu dengan uptime hingga 99,999%, website Anda bisa selalu online
selama 24 jam penuh. Dengan begitu, Anda bisa mengonlinekan website tanpa
rasa khawatir dengan downtime.