Learn To Style HTML Using CSS - MDN Web Docs
Có thể bạn quan tâm
- Guides
- CSS
- English (US)
- Remember language
- Deutsch
- Español
- Français
- 日本語
- 한국어
- Português (do Brasil)
- Русский
- 中文 (简体)
- 正體中文 (繁體)
- Prerequisites
- Modules
- Solving common CSS problems
- "CSS is weird"
- See also
- Complete beginners start here!
- Getting started with the web
- Getting started with the web
- Installing basic software
- What will your website look like?
- Dealing with files
- HTML basics
- CSS basics
- JavaScript basics
- Publishing your website
- How the web works
- HTML — Structuring the web
- Introduction to HTML
- Introduction to HTML
- Getting started with HTML
- What's in the head? Metadata in HTML
- HTML text fundamentals
- Creating hyperlinks
- Advanced text formatting
- Document and website structure
- Debugging HTML
- Marking up a letter
- Structuring a page of content
- Multimedia and embedding
- Multimedia and embedding
- Images in HTML
- Video and audio content
- From object to iframe — other embedding technologies
- Adding vector graphics to the web
- Responsive images
- Mozilla splash page
- HTML tables
- HTML tables
- HTML table basics
- HTML table advanced features and accessibility
- Structuring planet data
- CSS — Styling the web
- CSS first steps
- CSS first steps
- What is CSS?
- Getting started with CSS
- How CSS is structured
- How CSS works
- Styling a biography page
- CSS building blocks
- CSS building blocks
- CSS selectors
- Type, class, and ID selectors
- Attribute selectors
- Pseudo-classes and pseudo-elements
- Combinators
- Cascade, specificity, and inheritance
- Cascade layers
- The box model
- Backgrounds and borders
- Handling different text directions
- Overflowing content
- CSS values and units
- Sizing items in CSS
- Images, media, and form elements
- Styling tables
- Advanced styling effects
- Debugging CSS
- Organizing your CSS
- Fundamental CSS comprehension
- Creating fancy letterheaded paper
- A cool-looking box
- Styling text
- CSS styling text
- Fundamental text and font styling
- Styling lists
- Styling links
- Web fonts
- Typesetting a community school homepage
- CSS layout
- CSS layout
- Introduction to CSS layout
- Normal Flow
- Flexbox
- Grids
- Floats
- Positioning
- Multiple-column layout
- Responsive design
- Beginner's guide to media queries
- Legacy layout methods
- Supporting older browsers
- Fundamental layout comprehension
- JavaScript — Dynamic client-side scripting
- JavaScript first steps
- JavaScript first steps
- What is JavaScript?
- A first splash into JavaScript
- What went wrong? Troubleshooting JavaScript
- Storing the information you need — Variables
- Basic math in JavaScript — numbers and operators
- Handling text — strings in JavaScript
- Useful string methods
- Arrays
- Silly story generator
- JavaScript building blocks
- JavaScript building blocks
- Making decisions in your code — conditionals
- Looping code
- Functions — reusable blocks of code
- Build your own function
- Function return values
- Introduction to events
- Event bubbling
- Image gallery
- Introducing JavaScript objects
- Introducing JavaScript objects
- JavaScript object basics
- Object prototypes
- Object-oriented programming
- Classes in JavaScript
- Working with JSON
- Object building practice
- Adding features to our bouncing balls demo
- Asynchronous JavaScript
- Asynchronous JavaScript
- Introducing asynchronous JavaScript
- How to use promises
- How to implement a promise-based API
- Introducing workers
- Sequencing animations
- Client-side web APIs
- Client-side web APIs
- Introduction to web APIs
- Manipulating documents
- Fetching data from the server
- Third-party APIs
- Drawing graphics
- Video and Audio APIs
- Client-side storage
- Web forms — Working with user data
- Web form building blocks
- Web form building blocks
- Your first form
- How to structure a web form
- Basic native form controls
- The HTML5 input types
- Other form controls
- Styling web forms
- Advanced form styling
- UI pseudo-classes
- Client-side form validation
- Sending form data
- Advanced web form techniques
- How to build custom form controls
- Sending forms through JavaScript
- CSS property compatibility table for form controls
- HTML forms in legacy browsers
- Accessibility — Make the web usable by everyone
- Accessibility guides
- Accessibility
- What is accessibility?
- HTML: A good basis for accessibility
- CSS and JavaScript accessibility best practices
- WAI-ARIA basics
- Accessible multimedia
- Mobile accessibility
- Assessment: Accessibility troubleshooting
- Performance — Making websites fast and responsive
- Performance guides
- Web performance
- The "why" of web performance
- What is web performance?
- Perceived performance
- Measuring performance
- Multimedia: Images
- Multimedia: video
- JavaScript performance optimization
- HTML performance optimization
- CSS performance optimization
- The business case for web performance
- MathML — Writing mathematics with MathML
- MathML first steps
- MathML first steps
- Getting started with MathML
- MathML Text Containers
- MathML fractions and roots
- MathML scripted elements
- MathML tables
- Three famous mathematical formulas
- Games — Developing games for the web
- Guides and tutorials
- Introduction to game development for the Web
- Techniques for game development
- Tutorials
- Publishing games
- Tools and testing
- Client-side web development tools
- Understanding client-side web development tools
- Client-side tooling overview
- Command line crash course
- Package management basics
- Introducing a complete toolchain
- Deploying our app
- Introduction to client-side frameworks
- Introduction to client-side frameworks
- Framework main features
- React
- Getting started with React
- Beginning our React todo list
- Componentizing our React app
- React interactivity: Events and state
- React interactivity: Editing, filtering, conditional rendering
- Accessibility in React
- React resources
- Ember
- Getting started with Ember
- Ember app structure and componentization
- Ember interactivity: Events, classes and state
- Ember Interactivity: Footer functionality, conditional rendering
- Routing in Ember
- Ember resources and troubleshooting
- Vue
- Getting started with Vue
- Creating our first Vue component
- Rendering a list of Vue components
- Adding a new todo form: Vue events, methods, and models
- Styling Vue components with CSS
- Using Vue computed properties
- Vue conditional rendering: editing existing todos
- Vue refs and lifecycle methods for focus management
- Vue resources
- Svelte
- Getting started with Svelte
- Starting our Svelte to-do list app
- Dynamic behavior in Svelte: working with variables and props
- Componentizing our Svelte app
- Advanced Svelte: Reactivity, lifecycle, accessibility
- Working with Svelte stores
- TypeScript support in Svelte
- Deployment and next steps
- Angular
- Getting started with Angular
- Beginning our Angular todo list app
- Styling our Angular app
- Creating an item component
- Filtering our to-do items
- Building Angular applications and further resources
- Git and GitHub
- Git and GitHub
- Cross browser testing
- Cross browser testing
- Introduction to cross-browser testing
- Strategies for carrying out testing
- Handling common HTML and CSS problems
- Handling common JavaScript problems
- Handling common accessibility problems
- Implementing feature detection
- Introduction to automated testing
- Setting up your own test automation environment
- Server-side website programming
- First steps
- Server-side website programming first steps
- Introduction to the server side
- Client-Server Overview
- Server-side web frameworks
- Website security
- Django web framework (Python)
- Django Web Framework (Python)
- Django introduction
- Setting up a Django development environment
- Django Tutorial: The Local Library website
- Django Tutorial Part 2: Creating a skeleton website
- Django Tutorial Part 3: Using models
- Django Tutorial Part 4: Django admin site
- Django Tutorial Part 5: Creating our home page
- Django Tutorial Part 6: Generic list and detail views
- Django Tutorial Part 7: Sessions framework
- Django Tutorial Part 8: User authentication and permissions
- Django Tutorial Part 9: Working with forms
- Django Tutorial Part 10: Testing a Django web application
- Django Tutorial Part 11: Deploying Django to production
- Django web application security
- Assessment: DIY Django mini blog
- Express Web Framework (Node.js/JavaScript)
- Express web framework (Node.js/JavaScript)
- Express/Node introduction
- Setting up a Node development environment
- Express Tutorial: The Local Library website
- Express Tutorial Part 2: Creating a skeleton website
- Express Tutorial Part 3: Using a Database (with Mongoose)
- Express Tutorial Part 4: Routes and controllers
- Express Tutorial Part 5: Displaying library data
- Express Tutorial Part 6: Working with forms
- Express Tutorial Part 7: Deploying to production
- Further resources
- Common questions
- Common questions
- Use HTML to solve common problems
- Use CSS to solve common problems
- Solve common problems in your JavaScript code
- Web mechanics
- Tools and setup
- Design and accessibility
- Prerequisites
- Modules
- Solving common CSS problems
- "CSS is weird"
- See also
Cascading Style Sheets — or CSS — is the first technology you should start learning after HTML. While HTML is used to define the structure and semantics of your content, CSS is used to style it and lay it out. For example, you can use CSS to alter the font, color, size, and spacing of your content, split it into multiple columns, or add animations and other decorative features.
Prerequisites
You should learn the basics of HTML before attempting any CSS. We recommend that you work through our Introduction to HTML module first.
Once you understand the fundamentals of HTML, we recommend that you learn further HTML and CSS at the same time, moving back and forth between the two topics. This is because HTML is far more interesting and much more fun to learn when you apply CSS, and you can't learn CSS without knowing HTML.
Before starting this topic, you should also be familiar with using computers and using the web passively (i.e., just looking at it, consuming the content). You should have a basic work environment set up, as detailed in Installing basic software, and understand how to create and manage files, as detailed in Dealing with files — both of which are parts of our Getting started with the web complete beginner's module.
It is also recommended that you work through Getting started with the web before proceeding with this topic, especially if you are completely new to web development. However, much of what is covered in its CSS basics article is also covered in our CSS first steps module, albeit in a lot more detail.
Modules
This topic contains the following modules, in a suggested order for working through them. You should start with the first one.
CSS first stepsCSS (Cascading Style Sheets) is used to style and layout web pages — for example, to alter the font, color, size, and spacing of your content, split it into multiple columns, or add animations and other decorative features. This module provides a gentle beginning to your path towards CSS mastery with the basics of how it works, what the syntax looks like, and how you can start using it to add styling to HTML.
CSS building blocksThis module carries on where CSS first steps left off — now you've gained familiarity with the language and its syntax, and got some basic experience with using it, it's time to dive a bit deeper. This module looks at the cascade and inheritance, all the selector types we have available, units, sizing, styling backgrounds and borders, debugging, and lots more.
The aim here is to provide you with a toolkit for writing competent CSS and help you understand all the essential theory, before moving on to more specific disciplines like text styling and CSS layout.
CSS styling textWith the basics of the CSS language covered, the next CSS topic for you to concentrate on is styling text — one of the most common things you'll do with CSS. Here we look at text styling fundamentals, including setting font, boldness, italics, line and letter spacing, drop shadows, and other text features. We round off the module by looking at applying custom fonts to your page, and styling lists and links.
CSS layoutAt this point, we've already looked at CSS fundamentals, how to style text, and how to style and manipulate the boxes that your content sits inside. Now it's time to look at how to place your boxes in the right place with respect to the viewport, and one another. We have covered the necessary prerequisites so we can now dive deep into CSS layout, looking at different display settings, modern layout tools like flexbox, CSS grid, and positioning, and some of the legacy techniques you might still want to know about.
Solving common CSS problems
Use CSS to solve common problems provides links to sections of content explaining how to use CSS to solve very common problems when creating a web page.
From the beginning, you'll primarily apply colors to HTML elements and their backgrounds; change the size, shape, and position of elements; and add and define borders on elements. But there's not much you can't do once you have a solid understanding of even the basics of CSS. One of the best things about learning CSS is that once you know the fundamentals, usually you have a pretty good feel for what can and can't be done, even if you don't know how to do it yet!
"CSS is weird"
CSS works a bit differently from most programming languages and design tools you'll come across. Why does it work the way it does? In the following video, Miriam Suzanne provides a useful explanation of why CSS works as it does, and why it has evolved as it has:
See also
CSS on MDNThe main entry point for CSS documentation on MDN, where you'll find detailed reference documentation for all features of the CSS language. Want to know all the values a property can take? This is a good place to go.
Help improve MDN
Was this page helpful to you?YesNoLearn how to contribute.This page was last modified on Mar 5, 2024 by MDN contributors.
View this page on GitHub • Report a problem with this contentTừ khóa » Html And Css Tutorial For Beginners
-
CSS Tutorial - W3Schools
-
HTML Tutorial - W3Schools
-
HTML For Beginners The Easy Way: Start Learning HTML & CSS ...
-
HTML Tutorial For Beginners: HTML Crash Course - YouTube
-
HTML And CSS Tutorial For 2021 - COMPLETE Crash Course!
-
HTML & CSS Full Course - Beginner To Pro (2022) - YouTube
-
HTML & CSS Courses & Tutorials - Codecademy
-
Learn To Code HTML & CSS The Book
-
HTML And CSS Tutorial - Nanyang Technological University
-
HTML And CSS For Beginners | Udemy
-
Learn Web Development Basics – HTML, CSS, And JavaScript ...
-
CSS Tutorial - Tutorialspoint
-
HTML Tutorial - Tutorialspoint
-
HTML Tutorial For Beginners :Html Css Javascript Tutorial - Udemy