Skip to main content

Why Can't I Add Margin or Paddding

Lesson 55 from: Build a Responsive Website Using HTML5 & CSS3

Daniel Walter Scott

Why Can't I Add Margin or Paddding

Lesson 55 from: Build a Responsive Website Using HTML5 & CSS3

Daniel Walter Scott

buy this class

$00

$00
Sale Ends Soon!

starting under

$13/month*

Unlock this classplus 2000+ more >

Lesson Info

55. Why Can't I Add Margin or Paddding

Next Lesson: Rounded Corners

Lessons

Class Trailer

Getting Started

1

How This Class is Structured

01:41
2

What to Download

02:57

Introduction to HTML & CSS

3

Creating Our First Webpage

05:55
4

What is HTML5 & CSS3

08:24
5

Head vs. Body vs. Html Tag

09:01
6

Title & Description

05:54
7

What Code Editor Should I Use

02:42
8

Using Diy Tags

06:26
9

What is a CSS Class

09:05
10

How to Create Nested Divs

05:03
11

Class Project

05:24
12

External CSS

09:07
13

Creating Our Index Style Pages

12:16

Project 1: Restaurant Website

14

Testing Your Website

08:47
15

Check Your Code For Errors

11:01
16

What are HTML5 Structure Tags

05:47
17

Add HTML5 structure elements

16:02
18

How to Set the Color of the Background

05:10
19

Adding Images to a Website

04:38
20

How to Center an Image

01:14
21

Change the Font Size & Color

14:11
22

Make a Clickable Link

08:45
23

Stretching Background Image

05:38
24

Making a Div Tag Transparent

02:36
25

Simple Website Text Navigation

06:43
26

CSS Compound Classes

07:02
27

Class Project 02

02:05
28

Class Project 02 - COMPLETE

04:48
29

Add an Email Button to a Website

03:49
30

Add Google Maps to Your Website

11:25
31

Making a Website Live

16:50
32

Uploading via SFTP

11:50
33

Setting Up Our New Project

03:46

Project 2: Bike Repair Website

34

CSS Reset

15:22
35

Min-height vs. Height

07:01
36

Div Tags Onto One Line

05:23
37

Getting div tags onto one line using Flexbox in HTML & CSS

05:23
38

Evenly Spaced Div Tags

04:42
39

Two Div Tags of Different Sizes

07:13
40

Vertically Center Content

07:20
41

Class Project 3

02:51
42

Class Project 3 - COMPLETE

05:39
43

Change Default Fonts

04:19
44

Installing Google Fonts

12:44
45

What are PX & EM & REM

14:56
46

Change Line Height

04:33
47

SVG vs. JPG vs. PNG

07:04
48

How to Create a SVG, JPG, or PNG

11:00
49

Block Images vs. Background Images

08:32
50

Finishing Up Our Cards

09:10
51

Icons via Font Awesome

16:31
52

Making a Div Container Clickable

09:55
53

Box-sizing & Border-box

06:19
54

How to Make A Colored Button

07:46
55

Why Can't I Add Margin or Paddding

11:08
56

Rounded Corners

04:17
57

Drop Shadows

06:24
58

Backup Your Website

05:00
59

Reusing a Button Class

03:10
60

Class Project 04

02:58
61

Class Project 04 -COMPLETE

05:45
62

Adding a Horizontal Rule

03:51
63

Make Divs Wrap Onto Separate Lines

12:14
64

Hover Color & Animating a Button

03:33
65

Pseudo Classes

09:31
66

Simple Dropdown Navigation

20:04
67

Adding Our Dropdown to the Website

14:50
68

Useful Shortcuts and Tips in VS Code

13:28
69

Large Background Image

09:24
70

How to Connect 2 Pages

10:42
71

Simple PHP Form Work

17:49
72

Placeholder Form Text

05:46
73

Multi Line Form Text Box

02:18
74

Form Check Marks

03:04
75

Form Radio Button

06:07
76

Form Drop Down Menu

05:48
77

How to Style Your Form

12:55

Project 3: Responsive Portfolio Website

78

What does responsive website design mean

04:17
79

How to change a website layout size color when at different sizes using media queries

11:28
80

How to test your website on a tablet or mobile phone from Visual Studio Code

06:00
81

How to change the layout of a responsive website for mobile vs desktop

16:02
82

How to turn things on and off for mobile tablet & desktop responsive websites

06:03
83

What is pixel density responsive images pixel ratio dp px in webdesign

14:47
84

How to export responsive images for website from XD Photoshop Illustrator

05:11
85

How to add responsive images to website using 100% width in HTML & CSS

06:08
86

How to use srcset to change images in HTML for responsive website

10:15
87

How to add a css style to the first line of a p tag on a website (

11:18
88

How to make the header footer full width but the inside centered

05:36
89

Class Project 05 – Header design

03:12
90

Class Project 05 – Header design COMPLETE

06:25
91

How to use a span tag or span class in HTML to change text

10:32
92

How to pin the navigation to the top of a website fixed nav

03:17
93

How to make a simple responsive mobile menu using CSS only

08:21
94

What is Javascript vs Jquery in website web design

06:35
95

How to make a burger menu 3 line mobile navigation for a website

15:11
96

How to switch a menu nav from desktop to mobile phone

21:45

Project 4: Bootstrap Yogurt Website

97

Overview of what Bootstrap 4 is in website design

07:57
98

How to install Bootstrap 4 on a website using Visual Studio Code

06:27
99

Quick overview of how the Bootstrap Grid Layout works in VS Code

10:49
100

Quick overview of how Bootstrap Components works in VS Code

09:23
101

Quick overview of how Bootstrap CSS Styles works in VS Code

08:20
102

How to customize the default Bootstrap 4 css styles

13:51
103

How to use Bootstrap Layout Grid Experiment 1

10:20
104

How to make 100% header & uneven widths in Bootstrap 4

07:16
105

How to create uneven col widths in Bootstrap 4

07:27
106

How to add padding & margins using Bootstrap 4 in VS Code

12:03
107

How to change layout of Bootstrap depending on mobile or desktop

15:46
108

How to turn things on & off on your website using Bootstrap 4

05:30
109

Google Chrome Inspect

12:40
110

Add Shadows to Text & Boxes

07:06
111

Change the Default Buttons

06:16
112

Responsive Images in Bootstrap 4

09:34
113

How to Center Text & Div Tags

04:16
114

Customize the Bootstrap Navbar

07:29
115

Add Your Own Logo

03:58
116

Change the Default Nav Styles

12:12
117

Fix the Navigation to the Top

04:41
118

Col Images & Col Background

07:56
119

Bootstrap Border & Rounded Corners

04:20
120

Bootstrap 4 Carousels

05:13
121

Card Groups

03:29
122

Drop Shadows On Bootstrap Cards

02:25
123

Clickable Boxes in Bootstrap 4

04:02

Final Quiz

124

Final Quiz

Lesson Info

Why Can't I Add Margin or Paddding

Hello, frustrated people we can't add margin to the top of our button. We've styled in a tag and we want to push it either from the top margin or the bottom margin but it's not working. Why is it not working? It's because the display property is set to in line. So the quick version of this video is just put display in line block on your button and make sure you save it and then you can do it hang around for this whole video because we're going to talk about the different display properties block in line, block in line and we're going to do some fancy CSS where we connect a couple of classes and a tag together. Are you ready? Let's add top margin to a button. Alright. So remember in the last video we had problems putting padding or sorry, margin above this. Okay. And it's something to do with its display property. So I've created this like little throwaway bit of html. Okay, so you don't have to do this, you can play along if you want. But it's just a just a plain old text html document...

. We're going to talk about the main there's lots of display properties. We're going to talk about the main ones that will affect you as a kind of beginning web designer and which is in line and block. So there are some things that are displayed by block by default and what that means is let's look at a p tag with some some text actually let's add a chunk of text. So Lauren but in Another one is an H one. That's my default, what's called block level. Okay. And all this really means is let's add a couple more and I'm going to put in an unloaded list, which is a bullet point list with some list items, but I want like 10 of them. Okay. And inside of this, I'm going to put in items. Okay. So these are all block level. What that means is if I look at this, can you see that guy pushes that guy down onto his own line? He's his own block of stuff. This is a guy as a big block as well. All of these guys in their own little block, they push each other over the opposite for these guys are in line. Okay. And they're useful for things like let's say an attack. So I'm gonna put in a space tag. Okay. And this one's going to hash and it's going to be my link. Okay. And it's an in line. Okay. Which is giving us our problem, the difference between in line is can you see it didn't push everybody else are a Okay. Plays well with others. It works in line. Whereas block says you have to be in your own line online in line with an image if I need to add an image here. Okay, So I? M g the sources, images slash that one in going to give it a size, give it a height at least it's not too big. You can do heights kind of in the html which is kind of weird. Okay. It's in line so you can change them around. Okay. You can say actually I would like up here in my style. I'm not using a CSS sheet for this particular one just to save some time. So I'm going to say I want the images to be ah image please to be displayed property of let's be in line block actually know to be block. Okay. You block things out. You are now all by doing his own thing. Cool. So one of the properties for a tag here because it's in line. Okay. By default. Is that you can't put a height, you can do left and right. I can say actually I want an a tag that has um I want a big old margin on the right so imagine Imagine right, that works perfectly. 200 pixels. So look so it's got a big margin to the right. Okay. But I can't do a big old margin to the top, which we already know from our last video. Let's go 100 pixels to the top please. Doesn't do anything you like. Doesn't push it 100 pixels down. What you can do though is you can say actually a tag I'd like you to stop being in line and I want you to be a display. Okay. Of I don't want it to be blocked because block in this case would kind of not do what I wanted to do. Man having trouble. Come on, there we go because it's kind of pushing down to its own line. You're like actually it's kind of what I want. I want a bit of in between okay in the in between is I want you to stay in line okay in line but also be a bit blocky that does a bit of both. And basically what it's gonna do for us is it's going to stay in line. Okay so it's still on that same line as our paragraph. Let's get rid of the get rid of the image tag. He's making everything look a bit confusing. Okay so stay in this paragraph but allow me to do things like hitting okay or margin top. So they all have their natural ability. Say these list items. Remember these guys really want to be on their own lines, They're called block level. They're actually called, what are they called? I've got a special one for them. Okay so list items, we're going to say display please and they've got this one called where is there one list item which does the same as block. Okay with a few extra perks. And so instead of being blocked I want you to be in line and let's have a little look at what it does. See the list items are all stacked on the same line now there'll be lots of times where you need to leave it as the default. Occasionally though you're like actually just just be part of the gang. I want H one with a P tag right next to it because I've done some cool design stuff and I need to implement that. Whereas headings really want to be on their own line because they are block elements. Does that kind of help to recap? Okay, eight eggs by default are in line okay. Which means they stay on the same line as everybody else tags. H one's block. Okay there a display block property so they all be on their own line. But if you want a bit of both in line, block is a great little bit of both bitter burden line, better block and mainly what it's going to allow us to do now is we're gonna go back to this page, double click you that will kick you, drag him around, you go over here. Okay. Is I'm gonna say to my where are you? My button? I'd like you to be now I'm not going to do it for all of them because I could say at the top here I want all eight tags to be in line block but I'm not committed to you know, I don't want to do that for all of them. I'm just going to do it for this one and you're gonna be in line block block. Block block go now I get to do a margin at the top. Imagine top and we're going to put in. I have no idea. 20 pixels. Let's have a look. Not this one genius. All right. This one's not working save all. Have a little look still not working my button. Alright. So it's not working for the class applied to my A tag. So what I'm going to have to do is say actually I want there to be an A tag with my button applied. This is still not going to work. Oh this is a good juicy bit of information. So if I grab these two king and I say you would like you to do that. It's probably still not going to work. Still not cool because what's happening is what it's looking for in terms of the selector that I just made is that saying I want to find my button inside of an attack but it's not inside. I've got an a tag that is my button. Okay. It's not inside of it. Like we've done in the past where we've got you know hair box, an H. One that's inside here A box that is inside my main inside of it. It's actually just an a tag with a label of my button. So how do you fix that? Okay. It's weird spaces means kind of shows you like this kind of bread crumbs of like my button is inside of the attack. Okay. Whereas if I joined them up so there's no space between them, it says an a tag that is in my button, apply this stuff, let's save it, see if it works, it's still not working, come on, it's still not working. What else do we do? Alright I had a brain bender there and I'm leaving it in the course because it's really useful. Brain bender. I thought I knew what I was doing, I was like yeah so we just do this and we can join them up and that's why it was broken and it still wasn't working okay the reason it wasn't working, like I was adjusting this, I'm like man that works, I was checking syntax. The reason it wasn't working code was perfect. It was because we did this little throw down course. Okay I opened this up, remember the little test of one and I opened it up and kind of tested it in the browser and I made a connection between venus code and this page and then I just closed it down and went on my business and went on with this one and closed it down. And then I started and then what I didn't realize well what I forgot is that that connection that live connection got broken between my original page here and the s code because I kind of went off and did something else. Can only kind of tethered to one at a time. So now I'm gonna wear this, going, scratching my head going, I don't know how this works. Okay. And that's because I yeah, I went to this other page previewed it now, I'm going to have to close it down, open it back up so that the tether and connection between my new, well the existing site now I will show it to me a bit flustered. I am okay. So now it works alright. So we learned a few things. I want to wrap it up and I want to leave in the badness in there. Just you'll run into that problem. And it's one of those things where you're like, it's just not working. I'm going to bed and you wake up in the morning and we'll start working. Like it wasn't working last night. I promise. It's because you've closed down and reopened that up. So we learned a couple of things we learned about displays. Okay. And we displayed block which is our kind of block level stuff. That's why we say block level tag selectors when I've been talking okay, You've got in line okay. Which is things like our image tags and our tags. There's lots of in line um attributes elements, but there's some of them do a bit of both. That's what we wanted in this case on my button to allow me to do some margin on the top and the other nice thing. We worked out was this other bit of way of writing? CSS So we've done commas, okay, we did it here. Where are we comments? We said I'd like you to I'd like you to target card one and card to and card three. So commas do the ends if you put a space between things trying to find one that has a space now there's got to be one. Do we even have one? We do. So I want p tags inside of cards and apply this stuff, but only if there's a P tag inside of it. This one here is I would like an a tag with this class applied to it and you can kind of use that like it's applied to it literally like it's stuck right next to it. It's applied to the side. No space space bad. Alright. And we also learned you need to restart your browser preview. If you jump between different projects, go with dan. Getting lost in front of people. Hope it's well you will use it as a learning experience. That's what I'll call it. All right on to the next video

Class Materials

Bonus Materials with Purchase

Exercise Files
Completed Files

Ratings and Reviews

Viwosoft Technologies
 

Great tutorial - your clear instructions and concise explanations make learning HTML5 & CSS3 a breeze!

Student Work

RELATED ARTICLES

RELATED ARTICLES