DEV Community

Charity Parks
Charity Parks

Posted on

1

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:

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

h1 {
color: black;
}

</style>
</head>
<body>
<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>
</body>

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!

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (1)

Collapse
 
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

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay