- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1566 Articles for CSS
120 Views
Use the CSS :nth-last-child(n) selector to style every element that is the child of its parent, counting from the last child. You can try to run the following code to implement the :nth-last-child(n) selectorExampleLive Demo p:nth-last-child(4) { background: blue; color: white; } This is demo text 1. This is demo text 2. This is demo text 3. This is demo text 4. This is demo text 5. This is demo text 6. Output
2K+ Views
To create a link button with borders, you can try to run the following code −ExampleLive Demo a:link, a:visited { background-color: white; color: black; border: 1px solid blue; padding: 30px 30px; text-align: center; text-decoration: none; display: inline-block; } a:hover, a:active { background-color: red; color: white; } Demo Link
218 Views
To set different styles to hyperlinks, such as font-size, background color, etc, you can try to run the following code:ExampleLive Demo a.first:link {color:#ff0000;} a.first:visited {color:#0000ff;} a.first:hover {color:#ffcc00;} a.second:link {color:#ff0000;} a.second:visited {color:#0000ff;} a.second:hover {font-size:150%;} a.third:link {color:#ff0000;} a.third:visited {color:#0000ff;} a.third:hover {background:#66ff66;} Mouse over the below given links: Link changes color Link changes font-size Link changes background-color
90 Views
To style every elements that is the last child of its parent, use the CSS :last-child selector. You can try to run the following code to implement the :last-child selectorExampleLive Demo p:last-child { background: orange; } This is demo text1. This is demo text2. This is demo text3. Output
306 Views
To set min-height and max-height of an element using CSS, you can try to run the following code −ExampleLive Demo div { max-height: 550px; min-height: 450px; background-color: red; } Below is a div with maximum and minimum height. Resize the web browser to see the effect. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.
447 Views
To set the minimum and maximum width of an element, you can try to run the following codeExampleLive Demo div { max-width: 300px; min-width: 100px; background-color: red; } Below is a div with maximum and minimum width. Resize the web browser to see the effect. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. Output
137 Views
The margin property with value auto is used to horizontally center the element within its container. You can try to run the following code to implement margin: auto;ExampleLive Demo div { width: 200px; margin: auto; border: 2px dashed blue; } This is demo text This is horizontally centered because it has margin: auto; Output
300 Views
The margin property with value inherit is used to inherit an element from the parent element. You can try to run the following code to implement margin: inherit;ExampleLive Demo div { border: 2px solid blue; margin-left: 50px; } p.ex1 { margin-left: inherit; } Inheriting left margin from the parent element This is demo text with inherited left margin. Output