{"id":39,"date":"2024-05-05T22:29:49","date_gmt":"2024-05-05T22:29:49","guid":{"rendered":"https:\/\/dashbenton.com\/blog\/?p=39"},"modified":"2024-05-05T22:29:49","modified_gmt":"2024-05-05T22:29:49","slug":"how-to-make-a-gradient-in-html-and-css","status":"publish","type":"post","link":"https:\/\/dashbenton.com\/blog\/2024\/05\/05\/how-to-make-a-gradient-in-html-and-css\/","title":{"rendered":"How To: Make a Gradient in HTML and CSS"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To start on how to make a gradient using HTML and CSS, we have to choose between two types:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Manual CSS<\/li>\n\n\n\n<li>Using an Online Tool<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">1. Manual CSS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To use manual CSS to make a gradient, you first need to add some HTML:<\/p>\n\n\n\n<html>\n    <head>\n        <title>Gradient Test<\/title>\n    <\/head>\n    <body>\n        <p>This is text with a gradient background behind it<\/p>\n    <\/body>\n<\/html>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;html>\n    &lt;head>\n        &lt;title>Gradient Test&lt;\/title>\n        &lt;link rel=\"stylesheet\" href=\"style.css\">\n    &lt;\/head>\n    &lt;body>\n        &lt;p>This is text with a gradient background behind it&lt;\/p>\n    &lt;\/body>\n&lt;\/html><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, we actually have to add the color.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open up (or create if you haven&#8217;t already) <code>style.css<\/code> and enter:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>body {\n  background: rgb(2,0,36);\n  background: linear-gradient(__deg, rgba(&#91;r,g,b,a]) _%, rgba(&#91;r,g,b,a]) __%, rgba(0,212,255,1) ___%);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and replace:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>background: linear-gradient(__deg, rgba(__) _%, rgba(__) __%, rgba(__) ___%);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">with this (in order of spaces):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rotation (deg), r,g,b,a, start %, r,g,b,a, middle %, r,g,b,a, end %<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and then you&#8217;re done!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can see the finished project on <a href=\"https:\/\/github.com\/cwrayne\/gradient-html-css\/\" data-type=\"link\" data-id=\"https:\/\/github.com\/cwrayne\/gradient-html-css\/\">this GitHub repo<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Using an Online Tool<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To use an online tool, search up on whatever search engine you&#8217;re using, and type &#8220;gradient generator&#8221;. I use <a href=\"http:\/\/cssgradient.io\" data-type=\"link\" data-id=\"cssgradient.io\">cssgradient.io<\/a> but you can use whatever site.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Go through the process and copy the CSS text.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Write body { [put generated CSS here] } and replace the note with the CSS.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Finally, add some HTML to make the website work.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can see the finished project <a href=\"https:\/\/github.com\/cwrayne\/gradient-html-css\/\" data-type=\"link\" data-id=\"https:\/\/github.com\/cwrayne\/gradient-html-css\/\">here<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks for looking at this post; see you soon!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To start on how to make a gradient using HTML and CSS, we have to choose between two types: 1. Manual CSS To use manual CSS to make a gradient, you first need to add some HTML: Gradient Test This is text with a gradient background behind it Now, we actually have to add the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-39","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/dashbenton.com\/blog\/wp-json\/wp\/v2\/posts\/39","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dashbenton.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dashbenton.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dashbenton.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dashbenton.com\/blog\/wp-json\/wp\/v2\/comments?post=39"}],"version-history":[{"count":4,"href":"https:\/\/dashbenton.com\/blog\/wp-json\/wp\/v2\/posts\/39\/revisions"}],"predecessor-version":[{"id":42,"href":"https:\/\/dashbenton.com\/blog\/wp-json\/wp\/v2\/posts\/39\/revisions\/42"}],"wp:attachment":[{"href":"https:\/\/dashbenton.com\/blog\/wp-json\/wp\/v2\/media?parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dashbenton.com\/blog\/wp-json\/wp\/v2\/categories?post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dashbenton.com\/blog\/wp-json\/wp\/v2\/tags?post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}