User Tools

Site Tools


tanszek:oktatas:techcomm:cascading_style_sheets

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tanszek:oktatas:techcomm:cascading_style_sheets [2024/10/01 09:30] – [8. Background styling] kissatanszek:oktatas:techcomm:cascading_style_sheets [2024/10/01 10:32] (current) – [3. Defining CSS styles] kissa
Line 90: Line 90:
  
 <code CSS> <code CSS>
 +/* styles.css */
 p { p {
     color: blue;     color: blue;
Line 239: Line 240:
 ==== 9. Margin, padding and border ==== ==== 9. Margin, padding and border ====
  
-The ''margin'' is the outer space around an element, while the ''padding'' is the inner space between the content and the borderThe ''border'' defines the outline of the element. This is called the "box model."+The **box model** is a fundamental concept in CSS that describes how elements are structured and spaced on a webpage. Every HTML element is represented as a rectangular box consisting of four distinct areas: **margin****border**, **padding**, and the **content** itselfUnderstanding the box model is crucial for effective layout and design.
  
 {{:tanszek:oktatas:techcomm:pasted:20240905-153005.png}} {{:tanszek:oktatas:techcomm:pasted:20240905-153005.png}}
  
-<code CSS+The ''margin'' is the outer space around an element, while the ''padding'' is the inner space between the content and the border. The ''border'' defines the outline of the element. 
-div { + 
-    margin: 10px; +The example below shows how to format a button. Try what happens when you change the button's border, margin and padding properties! 
-    padding: 20px; + 
-    border: 1px solid black+<code XML
-    border-radius: 5px; +<!DOCTYPE html> 
-}+<html> 
 +<head> 
 +    <title>Styled Button Example</title> 
 +    <style> 
 +        .styled-button { 
 +            color: green; 
 +            background-color: lightgreen; 
 +            margin: 10px; 
 +            padding: 20px; 
 +            border: 1px solid red
 +            border-radius: 5px; 
 +        } 
 +    </style> 
 +</head> 
 +<body> 
 +    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> 
 +    <button class="styled-button">Click me!</button> 
 +    <p>Maecenas sapien arcu, finibus eget dignissim quis, placerat vel ante.</p> 
 +</body> 
 +</html>
 </code> </code>
  
Line 273: Line 293:
     font-weight: bold;     font-weight: bold;
     font-style: italic;     font-style: italic;
- 
     text-decoration: underline;     text-decoration: underline;
     text-align: justify;     text-align: justify;
 } }
 </code> </code>
 +
 +If you are interested, [[https://www.w3schools.com/css/tryit.asp?filename=trycss_text|try more here]].
  
  
 ==== 12. Exercise ==== ==== 12. Exercise ====
  
-Create the following webpage by using HTML and CSS. Use inline CSS for formatting the text, and also apply class-based and id-based selectors!+Create the following webpage using HTML and CSS. Use embedded CSS, and format the content with inline, class-based and id-based selectors!
  
-Feel free to use online resources (e.g. [[https://www.w3schools.com/css/|W3Schools CSS tutorial]]) as help.+Feel free to use online resources (e.g. [[https://www.w3schools.com/css/|W3Schools CSS tutorial]]) as help. The raw text of the webpage can be found below the screenshot.
  
 {{:tanszek:oktatas:techcomm:pasted:20240905-153937.png?600}} {{:tanszek:oktatas:techcomm:pasted:20240905-153937.png?600}}
tanszek/oktatas/techcomm/cascading_style_sheets.1727775038.txt.gz · Last modified: 2024/10/01 09:30 by kissa