HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<svg width="400" height="400" viewBox="0 0 141 141" fill="none" aria-labelledby="title description" >
<title id="title">Valentine's Day Chocolate Box</title>
<desc id="description">A Chocolate Box that opens up when hovering over it.</desc>
<g id="chocolate_box">
<g id="bottom">
<path id="heart_bottom_shadow" d="M70.5294 47.2283C64.4454 30.5983 33.8235 33.0686 33.8235 58.2184C33.8235 70.7487 43.1835 87.4218 70.5294 104.412C97.8753 87.4218 107.235 70.7487 107.235 58.2184C107.235 33.2134 76.6471 30.4997 70.5294 47.2283V47.2283Z" fill="url(#paint0_linear)" />
<path id="heart_bottom" d="M70.5294 46.3466C64.9134 31.1023 36.6471 33.3668 36.6471 56.4209C36.6471 67.907 45.2871 83.1908 70.5294 98.7654C95.7718 83.1908 104.412 67.907 104.412 56.4209C104.412 33.4995 76.1765 31.012 70.5294 46.3466Z" fill="url(#paint1_linear)" />
<g id="chocolate">
<circle id="Ellipse 3" cx="69" cy="86.0004" r="7" fill="url(#paint2_radial)" />
<rect id="Rectangle 9" x="61.7605" y="85.9659" width="10.5962" height="10.3544" rx="3" transform="rotate(-43.6167 61.7605 85.9659)" fill="#4D2E07" />
<rect id="Rectangle 14" x="66.9147" y="91.4976" width="7.57338" height="10.6194" rx="3" transform="rotate(-133.325 66.9147 91.4976)" fill="url(#paint3_linear)" />
</g>
<g id="chocolate_2">
<circle id="Ellipse 5" cx="83" cy="75.0004" r="7" fill="url(#paint4_radial)" />
<rect id="Rectangle 11" x="78.0215" y="69.5529" width="10.5962" height="10.3544" rx="3" transform="rotate(0.379638 78.0215 69.5529)" fill="#74391E" />
<rect id="Rectangle 16" x="85.6896" y="79.916" width="7.70499" height="10.8024" rx="3" transform="rotate(-179.744 85.6896 79.916)" fill="url(#paint5_linear)" />
</g>
<g id="chocolate_3">
<circle id="Ellipse 4" cx="69" cy="61.0004" r="7" fill="url(#paint6_radial)" />
<rect id="Rectangle 10" x="66.9211" y="53.5886" width="10.5962" height="10.3544" rx="3" transform="rotate(28.0076 66.9211 53.5886)" fill="#74391E" />
<rect id="Rectangle 15" x="68.6167" y="66.1321" width="7.57338" height="10.1735" rx="3" transform="rotate(-152.727 68.6167 66.1321)" fill="url(#paint7_linear)" />
</g>
<g id="chocolate_4">
<circle id="Ellipse 1" cx="49" cy="52.0004" r="7" fill="url(#paint8_radial)" />
<rect id="Rectangle 7" x="46.8623" y="45.0004" width="10.5962" height="10.3544" rx="3" transform="rotate(28.0076 46.8623 45.0004)" fill="#4D2E07" />
<rect id="Rectangle 12" x="46.7615" y="44.954" width="7.79979" height="10.3325" rx="3" transform="rotate(28.0076 46.7615 44.954)" fill="url(#paint9_linear)" />
</g>
<g id="chocolate_5">
<circle id="Ellipse 2" cx="55" cy="72.0004" r="7" fill="url(#paint10_radial)" />
<rect id="Rectangle 8" x="49.1595" y="67.4497" width="10.5962" height="10.3544" rx="3" transform="rotate(-7.01037 49.1595 67.4497)" fill="#E1BA92" />
<rect id="Rectangle 13" x="50.162" y="75.084" width="7.79979" height="10.6194" rx="3" transform="rotate(-97.6047 50.162 75.084)" fill="url(#paint11_linear)" />
</g>
</g>
<g id="top">
<path id="heart_top_shadow" d="M70.8089 47.1526C64.9734 30.4338 34.3181 32.4475 33.9433 57.5945C33.7566 70.1234 42.867 86.9341 69.9566 104.33C97.5527 87.7492 107.16 71.2175 107.347 58.6886C107.72 33.6863 77.1751 30.5171 70.8089 47.1526V47.1526Z" fill="url(#paint12_linear)" />
<path id="heart_top" d="M70.822 46.271C65.4338 30.9448 37.1368 32.7877 36.7933 55.8393C36.6221 67.3241 45.0333 82.735 70.0408 98.684C95.5124 83.4873 104.379 68.334 104.55 56.8492C104.892 33.9304 76.6969 31.0223 70.822 46.271V46.271Z" fill="url(#paint13_linear)" />
<mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="36" y="36" width="69" height="64">
<path id="heart_mask" d="M70.822 46.271C65.4338 30.9448 37.1368 32.7877 36.7933 55.8393C36.6221 67.3241 45.0333 82.735 70.0408 98.684C95.5124 83.4873 104.379 68.334 104.55 56.8492C104.892 33.9304 76.6969 31.0223 70.822 46.271V46.271Z" fill="url(#paint14_linear)" />
</mask>
<g mask="url(#mask0)">
<line id="ribbon" x1="29.8641" y1="35.7361" x2="91.9818" y2="95.0302" stroke="url(#paint15_linear)" stroke-width="10" />
<g id="bow">
<path id="side_four" d="M51.0649 56.6703C51.7171 55.0943 53.9163 55.0056 54.6933 56.524L56.9415 60.9173C57.6065 62.2169 56.7003 63.768 55.2417 63.8268L51.1063 63.9935C49.6477 64.0524 48.6195 62.5792 49.1777 61.2304L51.0649 56.6703Z" fill="url(#paint16_linear)" />
<path id="side_three" d="M53.8296 56.9246C52.1934 56.4425 51.873 54.265 53.3008 53.3319L57.4321 50.6323C58.6541 49.8337 60.2923 50.571 60.5048 52.0153L61.1074 56.1099C61.32 57.5542 59.9637 58.7322 58.5634 58.3196L53.8296 56.9246Z" fill="url(#paint17_linear)" />
<path id="side_two" d="M51.8688 53.3124C53.4251 54.0105 53.4494 56.2113 51.9089 56.9435L47.4517 59.0623C46.1333 59.689 44.6093 58.7378 44.5932 57.278L44.5475 53.1396C44.5314 51.6798 46.0339 50.6952 47.3659 51.2926L51.8688 53.3124Z" fill="url(#paint18_linear)" />
<path id="side_one" d="M54.2978 53.687C53.624 55.254 51.4239 55.3126 50.6677 53.7836L48.4799 49.36C47.8327 48.0515 48.7601 46.5129 50.2194 46.4741L54.3566 46.3639C55.8159 46.3251 56.8238 47.8121 56.2472 49.1532L54.2978 53.687Z" fill="url(#paint19_linear)" />
</g>
</g>
</g>
</g>
<defs>
<linearGradient id="paint0_linear" x1="70.5294" y1="36.6475" x2="70.5294" y2="104.412" gradientUnits="userSpaceOnUse">
<stop stop-color="#9A3436" />
<stop offset="1" stop-color="#D2484A" />
</linearGradient>
<linearGradient id="paint1_linear" x1="101.588" y1="49.3533" x2="70.5294" y2="98.7654" gradientUnits="userSpaceOnUse">
<stop stop-color="#AD3C3E" />
<stop offset="1" stop-color="#E44E51" />
</linearGradient>
<radialGradient id="paint2_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(69 86.0004) rotate(90) scale(7)">
<stop offset="0.5625" stop-color="#9B4749" />
<stop offset="1" stop-color="#FF8688" />
</radialGradient>
<linearGradient id="paint3_linear" x1="70.7014" y1="91.4976" x2="70.7014" y2="102.117" gradientUnits="userSpaceOnUse">
<stop stop-color="#6F430C" />
<stop offset="1" stop-color="#9C6841" stop-opacity="0" />
</linearGradient>
<radialGradient id="paint4_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(83 75.0004) rotate(90) scale(7)">
<stop offset="0.5625" stop-color="#9B4749" />
<stop offset="1" stop-color="#FF8688" />
</radialGradient>
<linearGradient id="paint5_linear" x1="89.5421" y1="79.916" x2="89.5421" y2="90.7184" gradientUnits="userSpaceOnUse">
<stop stop-color="#9C6841" />
<stop offset="1" stop-color="#9C6841" stop-opacity="0" />
</linearGradient>
<radialGradient id="paint6_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(69 61.0004) rotate(90) scale(7)">
<stop offset="0.5625" stop-color="#9B4749" />
<stop offset="1" stop-color="#FF8688" />
</radialGradient>
<linearGradient id="paint7_linear" x1="72.4034" y1="66.1321" x2="72.4034" y2="76.3057" gradientUnits="userSpaceOnUse">
<stop stop-color="#9C6841" />
<stop offset="1" stop-color="#9C6841" stop-opacity="0" />
</linearGradient>
<radialGradient id="paint8_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(49 52.0004) rotate(90) scale(7)">
<stop offset="0.5625" stop-color="#9B4749" />
<stop offset="1" stop-color="#FF8688" />
</radialGradient>
<linearGradient id="paint9_linear" x1="50.6614" y1="44.954" x2="50.6614" y2="55.2865" gradientUnits="userSpaceOnUse">
<stop stop-color="#6F430C" />
<stop offset="1" stop-color="#9C6841" stop-opacity="0" />
</linearGradient>
<radialGradient id="paint10_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(55 72.0004) rotate(90) scale(7)">
<stop offset="0.5625" stop-color="#9B4749" />
<stop offset="1" stop-color="#FF8688" />
</radialGradient>
<linearGradient id="paint11_linear" x1="54.0619" y1="75.084" x2="54.0619" y2="85.7034" gradientUnits="userSpaceOnUse">
<stop stop-color="#A97B4C" />
<stop offset="1" stop-color="#9C6841" stop-opacity="0" />
</linearGradient>
<linearGradient id="paint12_linear" x1="70.9666" y1="36.573" x2="69.9566" y2="104.33" gradientUnits="userSpaceOnUse">
<stop stop-color="#9A3436" />
<stop offset="1" stop-color="#D2484A" />
</linearGradient>
<linearGradient id="paint13_linear" x1="98" y1="36" x2="77" y2="82" gradientUnits="userSpaceOnUse">
<stop stop-color="#FF9C9E" />
<stop offset="0.833333" stop-color="#FF5659" />
</linearGradient>
<linearGradient id="paint14_linear" x1="70.9665" y1="36.573" x2="70.0408" y2="98.684" gradientUnits="userSpaceOnUse">
<stop stop-color="#FF5659" />
<stop offset="1" stop-color="#FF9698" />
</linearGradient>
<linearGradient id="paint15_linear" x1="82.0213" y1="88.3893" x2="40.226" y2="42.898" gradientUnits="userSpaceOnUse">
<stop offset="0.390625" stop-color="#FF8688" />
<stop offset="1" stop-color="#FF8688" stop-opacity="0" />
</linearGradient>
<linearGradient id="paint16_linear" x1="52.7207" y1="52.6693" x2="53.3251" y2="67.6571" gradientUnits="userSpaceOnUse">
<stop offset="0.421875" stop-color="#FF8688" />
<stop offset="1" stop-color="#FFE8E8" />
</linearGradient>
<linearGradient id="paint17_linear" x1="49.676" y1="55.7006" x2="64.5162" y2="53.5166" gradientUnits="userSpaceOnUse">
<stop offset="0.421875" stop-color="#FF8688" />
<stop offset="1" stop-color="#FFE8E8" />
</linearGradient>
<linearGradient id="paint18_linear" x1="55.8197" y1="55.0846" x2="40.8206" y2="55.2502" gradientUnits="userSpaceOnUse">
<stop offset="0.421875" stop-color="#FF8688" />
<stop offset="1" stop-color="#FFE8E8" />
</linearGradient>
<linearGradient id="paint19_linear" x1="52.5873" y1="57.665" x2="52.1882" y2="42.6703" gradientUnits="userSpaceOnUse">
<stop offset="0.421875" stop-color="#FF8688" />
<stop offset="1" stop-color="#FFE8E8" />
</linearGradient>
</defs>
</svg>
body {
background: #1e1f26;
min-height: 100vh;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
svg {
overflow: visible;
#chocolate_box {
cursor: pointer;
#top {
transition: transform 1s ease;
}
&:hover {
#top {
transform: translate(40px, -25px) rotate(10deg);
transition: transform 1s ease;
}
}
}
}
}
Also see: Tab Triggers