Found 1566 Articles for CSS

List with a blue left border using CSS

varun
Updated on 22-Jun-2020 06:46:14

137 Views

To add a blue left border to a list in CSS, you can try to run the following code −ExampleLive Demo                    ul {             border-left: 3px solid blue;             background-color: #gray;          }                     Countries                India          US          Australia           Output

Style every element that is the child of its parent, counting from the last child with CSS

Chandu yadav
Updated on 22-Jun-2020 06:05:54

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

Create a link button with borders using CSS

vanithasree
Updated on 30-Jun-2020 08:53:44

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    

Add different styles to hyperlinks using CSS

mkotla
Updated on 22-Jun-2020 06:00:28

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    

Style every elements that is the last child of its parent with CSS

George John
Updated on 22-Jun-2020 05:58:52

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

Set min-height and max-height of an element using CSS

varun
Updated on 30-Jun-2020 08:03:54

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.          

Set min-width and max-width of an element using CSS

Ankith Reddy
Updated on 22-Jun-2020 05:55:28

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

Set the height and width of an image using percent with CSS

radhakrishna
Updated on 22-Jun-2020 05:35:38

698 Views

To set the height and width of an image using %, you can try to run the following code −ExampleLive Demo                    img {             height: 50%;             width: 50%;          }                     Sized image in %          

Role of margin property with value auto using CSS

Arjun Thakur
Updated on 22-Jun-2020 05:31:06

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

Role of margin property with value inherit using CSS

Giri Raju
Updated on 22-Jun-2020 05:24:06

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

Advertisements