DEV Community

Charity Parks
Charity Parks

Posted on

Combining CSS & HTML in the same file...

CSS can be used by itself or with HTML. This post is going to go over how to use the two to make beautiful web pages.

Typically CSS is written in its own file but I'm going to show you how to use it in the HTML file. CSS is defined in the

section of an HTML page, within a <style> element.
For example:

<title>Our Summer Vacation</title>
<style type="text/css">
body {
font-family: Tahoma;
background-color: blue;

h1 {
color: black;

<h1>Daytona Beach, Florida</h1>
<p>We haven't been to Daytona in such a long time. Its beautiful here. Daytona reminds me of being a teenager. That was the first time I went on a vacation.</p>

This way you can have both your CSS and HTML together in a simple file! There is A LOT more styling out there for you to use. CSS also uses borders. When using borders you can define the height and width for the border itself. More on that in future posts!

Happy Coding!

Discussion (1)

cwicaksono profile image
Cahyo Wicaksono

I do this in the first time when create website, after finish I seperate CSS from HTML si the code is more easy to mainenance