You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As mentioned above, CSS has a concept of classes. These allow you to name a part of the HTML code and apply styles only to this part, without affecting other parts. This can be super helpful! Maybe you have two divs that are doing something different (like your header and your post). A class can help you make them look different.
183
183
184
-
Go ahead and name some parts of the HTML code. Replace the `div` that contains your header with the following:
184
+
Go ahead and name some parts of the HTML code. Replace the `header` that contains your header with the following:
We will now add declaration blocks to different selectors. Selectors starting with `.` relate to classes. There are many great tutorials and explanations about CSS on the Web that can help you understand the following code. For now, copy and paste it into your `blog/static/css/blog.css` file:
@@ -232,7 +232,6 @@ h4 {
232
232
233
233
.date {
234
234
color: #828282;
235
-
float: right;
236
235
}
237
236
238
237
.save {
@@ -262,9 +261,9 @@ h4 {
262
261
color: #000000;
263
262
}
264
263
265
-
.post.actions {
264
+
.post>.date,
265
+
.post>.actions {
266
266
float: right;
267
-
margin: auto10px;
268
267
}
269
268
270
269
.btn-default,
@@ -285,33 +284,33 @@ Then surround the HTML code which displays the posts with declarations of classe
Copy file name to clipboardExpand all lines: en/django_forms/README.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ Before we add the link, we need some icons to use as buttons for the link. For t
48
48
49
49
> Note: To download the SVG image, open the context menu on the link (usually by right-clicking on it) and select "Save link as". In the dialog asking you where to save the file, navigate to the `djangogirls` directory of your Django project, and within that to subdirectory `blog/templates/blog/icons/`, and save the file there.
50
50
51
-
It's time to open `blog/templates/blog/base.html` in the code editor. Now we can use this icon file inside the base template as follow. In the `div`named `container`inside `page-header``div` tag, we will add a link:
51
+
It's time to open `blog/templates/blog/base.html` in the code editor. Now we can use this icon file inside the base template as follow. In the `div`tag inside `header`section, we will add a link before `h1` tag:
@@ -285,15 +285,15 @@ Now we know how to add a new post. But what if we want to edit an existing one?
285
285
286
286
First, let's save the icon which represents the edit button. Download [pencil-fill.svg](https://raw.githubusercontent.com/twbs/icons/main/icons/pencil-fill.svg) and save it to the location `blog/templates/blog/icons/`.
287
287
288
-
Open `blog/templates/blog/post_detail.html` in the code editor and add the line
288
+
Open `blog/templates/blog/post_detail.html` in the code editor and add the following code inside `article` tag:
@@ -380,7 +380,7 @@ If you need more information about Django forms, you should read the documentati
380
380
381
381
Being able to create new posts by clicking a link is awesome! But right now, anyone who visits your site will be able to make a new blog post, and that's probably not something you want. Let's make it so the button shows up for you but not for anyone else.
382
382
383
-
Open `blog/templates/blog/base.html` in the code editor, find our `container``div` inside `page-header``div` and the anchor tag you put in there earlier. It should look like this:
383
+
Open `blog/templates/blog/base.html` in the code editor, find our `div` inside `header` and the anchor tag you put in there earlier. It should look like this:
-`<section></section>` defines a section in a document
117
+
-`<header></header>` specifies a header for a document or section
118
+
-`<main></main>` specifies the main content of a document
119
+
-`<aside></aside>` defines some content aside from the content it is placed in (like a sidebar)
120
+
-`<footer></footer>` defines a footer for a document or section
121
+
-`<time></time>` defines a specific time (or datetime)
114
122
115
123
Here's an example of a full template, copy and paste it into `blog/templates/blog/post_list.html`:
116
124
@@ -122,29 +130,29 @@ Here's an example of a full template, copy and paste it into `blog/templates/blo
122
130
<title>Django Girls blog</title>
123
131
</head>
124
132
<body>
125
-
<div>
133
+
<header>
126
134
<h1><ahref="/">Django Girls Blog</a></h1>
127
-
</div>
135
+
</header>
128
136
129
-
<div>
130
-
<p>published: 14.06.2014, 12:14</p>
137
+
<article>
138
+
<time>published: 14.06.2014, 12:14</time>
131
139
<h2><ahref="">My first post</a></h2>
132
140
<p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
133
-
</div>
141
+
</article>
134
142
135
-
<div>
136
-
<p>published: 14.06.2014, 12:14</p>
143
+
<article>
144
+
<time>published: 14.06.2014, 12:14</time>
137
145
<h2><ahref="">My second post</a></h2>
138
146
<p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut f.</p>
139
-
</div>
147
+
</article>
140
148
</body>
141
149
</html>
142
150
```
143
151
144
-
We've created three `div` sections here.
152
+
We've created one `header` section and two `article` section here.
145
153
146
-
- The first `div` element contains the title of our blog – it's a heading and a link
147
-
- Another two `div` elements contain our blog posts with a published date, `h2` with a post title that is clickable and two`p`s (paragraph) of text, one for the date and one for our blog post.
154
+
- The `header` element contains the title of our blog – it's a heading and a link
155
+
- Another two `article` elements contain our blog posts with a published date in `time` element, `h2` with a post title that is clickable and a`p` (paragraph) of text for our blog post.
0 commit comments