Hero Section Overview
The hero section is the first content users see after the header. It’s designed to grab attention with a vibrant gradient background, clear messaging, and a strong call-to-action button.What You’ll Learn
- Multi-color CSS gradients
- Text centering techniques
- Call-to-action button styling
- Anchor link navigation
Building the HTML
Create the Section
Use a semantic
<section> element with the hero class:The ID
hero-section allows other elements to link to this section using anchor links.Complete Hero HTML
Styling with CSS
Multi-Color Gradient Background
Create a vibrant diagonal gradient:135deg- Diagonal angle from top-left to bottom-rightvar(--color-primary) 0%- Starts with yellow (#FFE600)var(--color-primary-dark) 50%- Transitions to darker yellow at middle#FFD700 100%- Ends with gold color
Centering the Content
margin: 0 auto centers a block element horizontally when it has a defined max-width.
Title Styling
Subtitle Styling
Call-to-Action Button
display: inline-block allows the link to have padding and dimensions while not taking up the full width like a block element would.
Hover and Active States
translateY(-2px)- Moves element up 2 pixels (negative = up)translateY(2px)- Moves element down 2 pixelstranslateX(10px)- Moves element right 10 pixels
Smooth Scrolling
Enable smooth scrolling for anchor links:Responsive Considerations
Mobile Optimization
The hero section is already responsive because:- Fluid Padding: Uses
var(--spacing-2xl)which scales with the base font size - Centered Text:
text-align: centerworks on all screen sizes - Relative Font Sizes: Uses
remunits that scale based on user preferences - Flexible Container:
max-widthprevents content from being too wide, but allows it to shrink
Optional Media Query for Larger Screens
You can enhance the hero for larger screens:Visual Hierarchy
The hero section establishes clear visual hierarchy:- Title (largest, bold) - Main message
- Subtitle (medium, regular) - Supporting information
- CTA Button (bright color, prominent) - Action to take
Accessibility Features
Semantic Heading - Using
<h1> for the main title helps screen readersSufficient Contrast - Dark text on light gradient background is readable
Keyboard Accessible - The CTA link can be focused and activated with keyboard
Clear Purpose - Descriptive link text (“Ver productos”) instead of “Click here”
Complete Code Reference
HTML:/workspace/source/mi-tutorial/index.html:440-470
CSS: /workspace/source/mi-tutorial/src/style.css:840-909
Gradient Variations
Try these gradient alternatives:Subtle Two-Color Gradient
Radial Gradient (from center)
Animated Gradient
For advanced users, create an animated gradient:Next Steps
Product Catalog
Build the product grid that the CTA button scrolls to
Footer Component
Create a multi-column footer with links and info